Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
d8b2c529
提交
d8b2c529
authored
1月 17, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Worker: Add LogLevel enum.
上级
a675da25
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
30 行增加
和
26 行删除
+30
-26
LogLevel.h
worker/include/LogLevel.h
+13
-0
Logger.h
worker/include/Logger.h
+5
-11
Settings.h
worker/include/Settings.h
+4
-3
common.h
worker/include/common.h
+0
-4
Settings.cpp
worker/src/Settings.cpp
+8
-8
没有找到文件。
worker/include/LogLevel.h
0 → 100644
浏览文件 @
d8b2c529
#ifndef MS_LOG_LEVEL_H
#define MS_LOG_LEVEL_H
#include "common.h"
enum
class
LogLevel
:
uint8_t
{
DEBUG
=
2
,
WARN
=
1
,
ERROR
=
0
};
#endif
worker/include/Logger.h
浏览文件 @
d8b2c529
#ifndef MS_LOGGER_H
#ifndef MS_LOGGER_H
#define MS_LOGGER_H
#define MS_LOGGER_H
#include "
common
.h"
#include "
LogLevel
.h"
#include "Settings.h"
#include "Settings.h"
#include "handles/UnixStreamSocket.h"
#include "handles/UnixStreamSocket.h"
#include "Channel/UnixStreamSocket.h"
#include "Channel/UnixStreamSocket.h"
...
@@ -39,12 +39,6 @@
...
@@ -39,12 +39,6 @@
*/
*/
// #define MS_DEVEL
// #define MS_DEVEL
/*
* This macro must point to a unsigned int function, method or variable that
* returns the logging level.
*/
#define MS_CURRENT_LOG_LEVEL Settings::configuration.logLevel
class
Logger
class
Logger
{
{
public
:
public
:
...
@@ -62,7 +56,7 @@ public:
...
@@ -62,7 +56,7 @@ public:
inline
inline
bool
Logger
::
HasDebugLevel
()
bool
Logger
::
HasDebugLevel
()
{
{
return
(
MS_LOG_LEVEL_DEBUG
==
MS_CURRENT_LOG_LEVEL
);
return
(
LogLevel
::
DEBUG
==
Settings
::
configuration
.
logLevel
);
}
}
// NOTE: Each file including Logger.h MUST define its own MS_CLASS macro.
// NOTE: Each file including Logger.h MUST define its own MS_CLASS macro.
...
@@ -103,7 +97,7 @@ bool Logger::HasDebugLevel()
...
@@ -103,7 +97,7 @@ bool Logger::HasDebugLevel()
#define MS_DEBUG(desc, ...) \
#define MS_DEBUG(desc, ...) \
do \
do \
{ \
{ \
if (
MS_LOG_LEVEL_DEBUG == MS_CURRENT_LOG_LEVEL
) \
if (
LogLevel::DEBUG == Settings::configuration.logLevel
) \
{ \
{ \
int ms_logger_written = std::snprintf(Logger::buffer, MS_LOGGER_BUFFER_SIZE, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
int ms_logger_written = std::snprintf(Logger::buffer, MS_LOGGER_BUFFER_SIZE, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, ms_logger_written); \
Logger::channel->SendLog(Logger::buffer, ms_logger_written); \
...
@@ -114,7 +108,7 @@ bool Logger::HasDebugLevel()
...
@@ -114,7 +108,7 @@ bool Logger::HasDebugLevel()
#define MS_DEBUG_STD(desc, ...) \
#define MS_DEBUG_STD(desc, ...) \
do \
do \
{ \
{ \
if (
MS_LOG_LEVEL_DEBUG == MS_CURRENT_LOG_LEVEL
) \
if (
LogLevel::DEBUG == Settings::configuration.logLevel
) \
{ \
{ \
std::fprintf(stdout, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \
std::fprintf(stdout, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \
std::fflush(stdout); \
std::fflush(stdout); \
...
@@ -125,7 +119,7 @@ bool Logger::HasDebugLevel()
...
@@ -125,7 +119,7 @@ bool Logger::HasDebugLevel()
#define MS_WARN(desc, ...) \
#define MS_WARN(desc, ...) \
do \
do \
{ \
{ \
if (
MS_LOG_LEVEL_WARN <= MS_CURRENT_LOG_LEVEL
) \
if (
LogLevel::WARN <= Settings::configuration.logLevel
) \
{ \
{ \
int ms_logger_written = std::snprintf(Logger::buffer, MS_LOGGER_BUFFER_SIZE, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
int ms_logger_written = std::snprintf(Logger::buffer, MS_LOGGER_BUFFER_SIZE, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, ms_logger_written); \
Logger::channel->SendLog(Logger::buffer, ms_logger_written); \
...
...
worker/include/Settings.h
浏览文件 @
d8b2c529
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define MS_SETTINGS_H
#define MS_SETTINGS_H
#include "common.h"
#include "common.h"
#include "logLevel.h"
#include "Channel/Request.h"
#include "Channel/Request.h"
#include <map>
#include <map>
#include <string>
#include <string>
...
@@ -13,7 +14,7 @@ public:
...
@@ -13,7 +14,7 @@ public:
// Struct holding the configuration.
// Struct holding the configuration.
struct
Configuration
struct
Configuration
{
{
uint8_t
logLevel
{
MS_LOG_LEVEL_
DEBUG
};
LogLevel
logLevel
{
LogLevel
::
DEBUG
};
std
::
string
rtcListenIPv4
;
std
::
string
rtcListenIPv4
;
std
::
string
rtcListenIPv6
;
std
::
string
rtcListenIPv6
;
uint16_t
rtcMinPort
{
10000
};
uint16_t
rtcMinPort
{
10000
};
...
@@ -42,8 +43,8 @@ public:
...
@@ -42,8 +43,8 @@ public:
static
struct
Configuration
configuration
;
static
struct
Configuration
configuration
;
private
:
private
:
static
std
::
map
<
std
::
string
,
uint8_t
>
string2LogLevel
;
static
std
::
map
<
std
::
string
,
LogLevel
>
string2LogLevel
;
static
std
::
map
<
uint8_t
,
std
::
string
>
logLevel2String
;
static
std
::
map
<
LogLevel
,
std
::
string
>
logLevel2String
;
};
};
#endif
#endif
worker/include/common.h
浏览文件 @
d8b2c529
...
@@ -11,10 +11,6 @@
...
@@ -11,10 +11,6 @@
#define MS_APP_NAME "mediasoup"
#define MS_APP_NAME "mediasoup"
#define MS_PROCESS_NAME "mediasoup-worker"
#define MS_PROCESS_NAME "mediasoup-worker"
#define MS_LOG_LEVEL_DEBUG 2
#define MS_LOG_LEVEL_WARN 1
#define MS_LOG_LEVEL_ERROR 0
// Detect Little-Endian or Big-Endian CPU.
// Detect Little-Endian or Big-Endian CPU.
// NOTE: If the macro MS_LITTLE_ENDIAN or MS_BIG_ENDIAN is already defined
// NOTE: If the macro MS_LITTLE_ENDIAN or MS_BIG_ENDIAN is already defined
// then don't autodetect it.
// then don't autodetect it.
...
...
worker/src/Settings.cpp
浏览文件 @
d8b2c529
...
@@ -24,17 +24,17 @@ bool IsBindableIP(const std::string &ip, int family, int* _bind_err);
...
@@ -24,17 +24,17 @@ bool IsBindableIP(const std::string &ip, int family, int* _bind_err);
/* Class variables. */
/* Class variables. */
struct
Settings
::
Configuration
Settings
::
configuration
;
struct
Settings
::
Configuration
Settings
::
configuration
;
std
::
map
<
std
::
string
,
uint8_t
>
Settings
::
string2LogLevel
=
std
::
map
<
std
::
string
,
LogLevel
>
Settings
::
string2LogLevel
=
{
{
{
"debug"
,
MS_LOG_LEVEL_
DEBUG
},
{
"debug"
,
LogLevel
::
DEBUG
},
{
"warn"
,
MS_LOG_LEVEL_
WARN
},
{
"warn"
,
LogLevel
::
WARN
},
{
"error"
,
MS_LOG_LEVEL_
ERROR
}
{
"error"
,
LogLevel
::
ERROR
}
};
};
std
::
map
<
uint8_t
,
std
::
string
>
Settings
::
logLevel2String
=
std
::
map
<
LogLevel
,
std
::
string
>
Settings
::
logLevel2String
=
{
{
{
MS_LOG_LEVEL_
DEBUG
,
"debug"
},
{
LogLevel
::
DEBUG
,
"debug"
},
{
MS_LOG_LEVEL_
WARN
,
"warn"
},
{
LogLevel
::
WARN
,
"warn"
},
{
MS_LOG_LEVEL_
ERROR
,
"error"
}
{
LogLevel
::
ERROR
,
"error"
}
};
};
/* Class methods. */
/* Class methods. */
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论