Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
c290cb2b
提交
c290cb2b
authored
12月 11, 2015
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
worker: rename process name to mediasoup-worker and improve logger.
上级
57fe729f
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
46 行增加
和
46 行删除
+46
-46
Makefile
mediasoup-worker/Makefile
+9
-12
Logger.h
mediasoup-worker/include/Logger.h
+30
-28
Settings.h
mediasoup-worker/include/Settings.h
+1
-1
common.h
mediasoup-worker/include/common.h
+1
-0
Logger.cpp
mediasoup-worker/src/Logger.cpp
+4
-2
core_grammar.rl
mediasoup-worker/src/core_grammar.rl
+0
-2
main.cpp
mediasoup-worker/src/main.cpp
+1
-1
没有找到文件。
mediasoup-worker/Makefile
浏览文件 @
c290cb2b
APP_NAME
:=
mediasoup
APP_NAME
:=
mediasoup-worker
#
#
# Compiler.
# Compiler.
...
@@ -25,7 +24,6 @@ DEV_FLAGS := $(DO_DEBUG_SYMBOLS) $(DO_SANITIZE) $(DO_OPTIMIZE) $(DO_PEDANTIC)
...
@@ -25,7 +24,6 @@ DEV_FLAGS := $(DO_DEBUG_SYMBOLS) $(DO_SANITIZE) $(DO_OPTIMIZE) $(DO_PEDANTIC)
#
#
# -DMS_DEVEL enables MS_TRACE().
# -DMS_DEVEL enables MS_TRACE().
#
#
# Settings.
# Settings.
#
#
...
@@ -83,19 +81,18 @@ CXXFLAGS += -std=c++11 -Wall $(DEV_FLAGS)
...
@@ -83,19 +81,18 @@ CXXFLAGS += -std=c++11 -Wall $(DEV_FLAGS)
LDFLAGS
+=
$
(
foreach lib,
$(SYSTEM_LIBS)
,
-l
$(lib)
)
LDFLAGS
+=
$
(
foreach lib,
$(SYSTEM_LIBS)
,
-l
$(lib)
)
LDFLAGS
+=
$(
shell
pkg-config
--libs
"
$(PKG_LIBS)
"
)
LDFLAGS
+=
$(
shell
pkg-config
--libs
"
$(PKG_LIBS)
"
)
#
#
# Targets.
# Targets.
#
#
# This indicates that
"all", APP_NAME, "check_pkg_libs" and "clean" are
# This indicates that
those names are "phony targets". Therefore calling
# "
phony targets". Therefore calling "make XXXX" should execute the content of its
# "
make XXXX" should execute the content of its build rules, even if a newer
#
build rules, even if a newer
file named "XXXX" exists.
# file named "XXXX" exists.
.PHONY
:
all $(APP_NAME) check_pkg_libs echo
_all_objs clean submodules doc
.PHONY
:
default $(APP_NAME) check_pkg_libs echo_compiling
_all_objs clean submodules doc
# This is first build rule in the Makefile, and so executing "make" and executing
# This is first build rule in the Makefile, and so executing "make" and executing
# "make
all
" are the same. The target simply depends on $(APP_NAME).
# "make
default
" are the same. The target simply depends on $(APP_NAME).
all
:
$(APP_NAME)
default
:
$(APP_NAME)
# The app depends on the object files (which are automatically built using the
# The app depends on the object files (which are automatically built using the
# predefined build rules, nothing needs to be given explicitly for them).
# predefined build rules, nothing needs to be given explicitly for them).
...
@@ -103,7 +100,7 @@ all: $(APP_NAME)
...
@@ -103,7 +100,7 @@ all: $(APP_NAME)
# the same name as the app. Note that LINK.cc makes use of CXX, CXXFLAGS,
# the same name as the app. Note that LINK.cc makes use of CXX, CXXFLAGS,
# LFLAGS, etc. LINK.cc is usually defined as: $(CXX) $(CXXFLAGS) $(CPPFLAGS)
# LFLAGS, etc. LINK.cc is usually defined as: $(CXX) $(CXXFLAGS) $(CPPFLAGS)
# $(LDFLAGS) $(TARGET_ARCH).
# $(LDFLAGS) $(TARGET_ARCH).
$(APP_NAME)
:
check_pkg_libs echo_all_objs $(ALL_OBJS)
$(APP_NAME)
:
check_pkg_libs echo_
compiling_
all_objs $(ALL_OBJS)
@
mkdir
-p
$(APP_BIN_DIR)
@
mkdir
-p
$(APP_BIN_DIR)
@
echo
"INFO: linking .o objects and libraries into
$(APP_BIN_DIR)
/
$(APP_NAME)
..."
@
echo
"INFO: linking .o objects and libraries into
$(APP_BIN_DIR)
/
$(APP_NAME)
..."
$
(
LINK.cc
)
$(ALL_OBJS)
$(DEP_LIBS)
-o
$(APP_BIN_DIR)
/
$(APP_NAME)
$
(
LINK.cc
)
$(ALL_OBJS)
$(DEP_LIBS)
-o
$(APP_BIN_DIR)
/
$(APP_NAME)
...
@@ -114,7 +111,7 @@ check_pkg_libs:
...
@@ -114,7 +111,7 @@ check_pkg_libs:
@
echo
"INFO: checking required PKG libraries (
$
(strip
$(PKG_LIBS)
)) ..."
@
echo
"INFO: checking required PKG libraries (
$
(strip
$(PKG_LIBS)
)) ..."
@
pkg-config
--exists
--print-errors
"
$(PKG_LIBS)
"
@
pkg-config
--exists
--print-errors
"
$(PKG_LIBS)
"
echo_all_objs
:
echo_
compiling_
all_objs
:
@
echo
"INFO: compiling source files into .o object files ..."
@
echo
"INFO: compiling source files into .o object files ..."
# This target removes the built app and the generated object files. The @ symbol
# This target removes the built app and the generated object files. The @ symbol
...
...
mediasoup-worker/include/Logger.h
浏览文件 @
c290cb2b
...
@@ -36,13 +36,8 @@ extern "C"
...
@@ -36,13 +36,8 @@ extern "C"
*
*
* - MS_TRACE();
* - MS_TRACE();
* - MS_DEBUG("starting worker %d", num);
* - MS_DEBUG("starting worker %d", num);
*
* Output:
* TRACE: [worker #1] Worker.cpp:93 | void Worker::Run()
* DEBUG: [worker #1] Worker.cpp:94 | void Worker::Run() | starting worker 1
*/
*/
/*
/*
* Call the compiler with -DMS_DEVEL for more verbose logs.
* Call the compiler with -DMS_DEVEL for more verbose logs.
*/
*/
...
@@ -57,14 +52,16 @@ extern "C"
...
@@ -57,14 +52,16 @@ extern "C"
class
Logger
class
Logger
{
{
public
:
public
:
static
void
Init
(
const
std
::
string
name
);
static
void
Init
(
const
std
::
string
id
);
static
const
char
*
GetProcessName
();
static
const
char
*
GetProcessName
();
static
const
char
*
GetProcessMinName
();
static
void
EnableSyslog
();
static
void
EnableSyslog
();
static
bool
IsSyslogEnabled
();
static
bool
IsSyslogEnabled
();
static
bool
HasDebugLevel
();
static
bool
HasDebugLevel
();
private
:
private
:
static
std
::
string
processName
;
static
std
::
string
processName
;
static
std
::
string
processMinName
;
static
bool
isSyslogEnabled
;
static
bool
isSyslogEnabled
;
};
};
...
@@ -76,6 +73,12 @@ const char* Logger::GetProcessName()
...
@@ -76,6 +73,12 @@ const char* Logger::GetProcessName()
return
Logger
::
processName
.
c_str
();
return
Logger
::
processName
.
c_str
();
}
}
inline
const
char
*
Logger
::
GetProcessMinName
()
{
return
Logger
::
processMinName
.
c_str
();
}
inline
inline
bool
Logger
::
IsSyslogEnabled
()
bool
Logger
::
IsSyslogEnabled
()
{
{
...
@@ -98,27 +101,27 @@ bool Logger::HasDebugLevel()
...
@@ -98,27 +101,27 @@ bool Logger::HasDebugLevel()
#else
#else
#define _MS_LOG_STR "[%s] %s::%s()"
#define _MS_LOG_STR "[%s] %s::%s()"
#define _MS_LOG_STR_DESC _MS_LOG_STR " | "
#define _MS_LOG_STR_DESC _MS_LOG_STR " | "
#define _MS_LOG_ARG Logger::GetProcessName(), MS_CLASS, __FUNCTION__
#define _MS_LOG_ARG Logger::GetProcess
Min
Name(), MS_CLASS, __FUNCTION__
#endif
#endif
#define _MS_TO_STDOUT(
prefix
) \
#define _MS_TO_STDOUT() \
if (!Logger::IsSyslogEnabled()) \
if (!Logger::IsSyslogEnabled()) \
{ \
{ \
std::fprintf(stdout,
prefix
_MS_LOG_STR "\n", _MS_LOG_ARG); \
std::fprintf(stdout, _MS_LOG_STR "\n", _MS_LOG_ARG); \
fflush(stdout); \
fflush(stdout); \
}
}
#define _MS_TO_STDOUT_DESC(
prefix,
desc, ...) \
#define _MS_TO_STDOUT_DESC(desc, ...) \
if (!Logger::IsSyslogEnabled()) \
if (!Logger::IsSyslogEnabled()) \
{ \
{ \
std::fprintf(stdout,
prefix
_MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
std::fprintf(stdout, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
fflush(stdout); \
fflush(stdout); \
}
}
#define _MS_TO_STDERR_DESC(
prefix,
desc, ...) \
#define _MS_TO_STDERR_DESC(desc, ...) \
if (!Logger::IsSyslogEnabled()) \
if (!Logger::IsSyslogEnabled()) \
{ \
{ \
std::fprintf(stderr,
prefix
_MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
std::fprintf(stderr, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
fflush(stderr); \
fflush(stderr); \
}
}
...
@@ -143,13 +146,12 @@ bool Logger::HasDebugLevel()
...
@@ -143,13 +146,12 @@ bool Logger::HasDebugLevel()
* LOG_DEBUG 7 debug-level messages
* LOG_DEBUG 7 debug-level messages
*/
*/
#ifdef MS_DEVEL
#ifdef MS_DEVEL
#define MS_TRACE() \
#define MS_TRACE() \
do \
do \
{ \
{ \
_MS_TO_STDOUT(
"TRACE: "
); \
_MS_TO_STDOUT(); \
_MS_TO_SYSLOG(LOG_DEBUG, "TRACE
:
"); \
_MS_TO_SYSLOG(LOG_DEBUG, "TRACE "); \
} \
} \
while (0)
while (0)
#else
#else
...
@@ -161,8 +163,8 @@ bool Logger::HasDebugLevel()
...
@@ -161,8 +163,8 @@ bool Logger::HasDebugLevel()
{ \
{ \
if (LOG_DEBUG == MS_GET_LOG_LEVEL) \
if (LOG_DEBUG == MS_GET_LOG_LEVEL) \
{ \
{ \
_MS_TO_STDOUT_DESC(
"DEBUG: ",
desc, ##__VA_ARGS__); \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_DEBUG, "DEBUG
:
", desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_DEBUG, "DEBUG ", desc, ##__VA_ARGS__); \
} \
} \
} \
} \
while (0)
while (0)
...
@@ -172,8 +174,8 @@ bool Logger::HasDebugLevel()
...
@@ -172,8 +174,8 @@ bool Logger::HasDebugLevel()
{ \
{ \
if (LOG_INFO <= MS_GET_LOG_LEVEL) \
if (LOG_INFO <= MS_GET_LOG_LEVEL) \
{ \
{ \
_MS_TO_STDOUT_DESC(
"INFO: ",
desc, ##__VA_ARGS__); \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_INFO, "INFO
:
", desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_INFO, "INFO ", desc, ##__VA_ARGS__); \
} \
} \
} \
} \
while (0)
while (0)
...
@@ -183,8 +185,8 @@ bool Logger::HasDebugLevel()
...
@@ -183,8 +185,8 @@ bool Logger::HasDebugLevel()
{ \
{ \
if (LOG_NOTICE <= MS_GET_LOG_LEVEL) \
if (LOG_NOTICE <= MS_GET_LOG_LEVEL) \
{ \
{ \
_MS_TO_STDOUT_DESC(
"NOTICE: ",
desc, ##__VA_ARGS__); \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_NOTICE, "NOTICE
:
", desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_NOTICE, "NOTICE ", desc, ##__VA_ARGS__); \
} \
} \
} \
} \
while (0)
while (0)
...
@@ -194,8 +196,8 @@ bool Logger::HasDebugLevel()
...
@@ -194,8 +196,8 @@ bool Logger::HasDebugLevel()
{ \
{ \
if (LOG_WARNING <= MS_GET_LOG_LEVEL) \
if (LOG_WARNING <= MS_GET_LOG_LEVEL) \
{ \
{ \
_MS_TO_STDERR_DESC(
"WARN: ",
desc, ##__VA_ARGS__); \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_WARNING, "WARN
:
", desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_WARNING, "WARN ", desc, ##__VA_ARGS__); \
} \
} \
} \
} \
while (0)
while (0)
...
@@ -203,16 +205,16 @@ bool Logger::HasDebugLevel()
...
@@ -203,16 +205,16 @@ bool Logger::HasDebugLevel()
#define MS_ERROR(desc, ...) \
#define MS_ERROR(desc, ...) \
do \
do \
{ \
{ \
_MS_TO_STDERR_DESC(
"ERROR: ",
desc, ##__VA_ARGS__); \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_ERR, "ERROR
:
", desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_ERR, "ERROR ", desc, ##__VA_ARGS__); \
} \
} \
while (0)
while (0)
#define MS_CRIT(desc, ...) \
#define MS_CRIT(desc, ...) \
do \
do \
{ \
{ \
_MS_TO_STDERR_DESC(
"CRIT: ",
desc, ##__VA_ARGS__); \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_ERR, "CRIT
:
", desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_ERR, "CRIT ", desc, ##__VA_ARGS__); \
} \
} \
while (0)
while (0)
...
...
mediasoup-worker/include/Settings.h
浏览文件 @
c290cb2b
...
@@ -15,7 +15,7 @@ public:
...
@@ -15,7 +15,7 @@ public:
// Struct holding the configuration.
// Struct holding the configuration.
struct
Configuration
struct
Configuration
{
{
unsigned
int
logLevel
{
LOG_
DEBUG
};
unsigned
int
logLevel
{
LOG_
INFO
};
bool
useSyslog
{
false
};
bool
useSyslog
{
false
};
unsigned
int
syslogFacility
{
LOG_USER
};
unsigned
int
syslogFacility
{
LOG_USER
};
...
...
mediasoup-worker/include/common.h
浏览文件 @
c290cb2b
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <arpa/inet.h> // htonl(), htons(), ntohl(), ntohs()
#include <arpa/inet.h> // htonl(), htons(), ntohl(), ntohs()
#define MS_PROCESS_NAME "mediasoup-worker"
#define MS_PROCESS_NAME "mediasoup-worker"
#define MS_PROCESS_MIN_NAME "worker"
#define MS_BYTE uint8_t
#define MS_BYTE uint8_t
#define MS_2BYTES uint16_t
#define MS_2BYTES uint16_t
...
...
mediasoup-worker/src/Logger.cpp
浏览文件 @
c290cb2b
...
@@ -5,13 +5,15 @@
...
@@ -5,13 +5,15 @@
/* Static variables. */
/* Static variables. */
std
::
string
Logger
::
processName
;
std
::
string
Logger
::
processName
;
std
::
string
Logger
::
processMinName
;
bool
Logger
::
isSyslogEnabled
=
false
;
bool
Logger
::
isSyslogEnabled
=
false
;
/* Static methods. */
/* Static methods. */
void
Logger
::
Init
(
const
std
::
string
name
)
void
Logger
::
Init
(
const
std
::
string
id
)
{
{
Logger
::
processName
=
name
;
Logger
::
processName
=
MS_PROCESS_NAME
"@"
+
id
;
Logger
::
processMinName
=
MS_PROCESS_MIN_NAME
"@"
+
id
;
MS_TRACE
();
MS_TRACE
();
}
}
...
...
mediasoup-worker/src/core_grammar.rl
浏览文件 @
c290cb2b
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
CRLF = "\r\n";
CRLF = "\r\n";
SP = 0x20; # Space.
SP = 0x20; # Space.
DIGIT = "0".."9";
DIGIT = "0".."9";
ALPHA = "a".."z" | "A".."Z";
ALPHA = "a".."z" | "A".."Z";
alphanum = ALPHA | DIGIT;
alphanum = ALPHA | DIGIT;
...
@@ -51,5 +50,4 @@
...
@@ -51,5 +50,4 @@
unicast_address = IPv4address | IPv6address | FQDN; # NOTE: let's remove non_ws_string.
unicast_address = IPv4address | IPv6address | FQDN; # NOTE: let's remove non_ws_string.
multicast_address = IPv4address_multicast | IPv6address_multicast | FQDN; # NOTE: let's remove non_ws_string.
multicast_address = IPv4address_multicast | IPv6address_multicast | FQDN; # NOTE: let's remove non_ws_string.
}%%
}%%
mediasoup-worker/src/main.cpp
浏览文件 @
c290cb2b
...
@@ -30,7 +30,7 @@ int main(int argc, char* argv[])
...
@@ -30,7 +30,7 @@ int main(int argc, char* argv[])
if
(
argc
==
1
)
if
(
argc
==
1
)
MS_EXIT_FAILURE
(
"process id must be given as first argument"
);
MS_EXIT_FAILURE
(
"process id must be given as first argument"
);
id
=
MS_PROCESS_NAME
"#"
+
std
::
string
(
argv
[
1
]);
id
=
std
::
string
(
argv
[
1
]);
Logger
::
Init
(
id
);
Logger
::
Init
(
id
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论