Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
e320f86b
提交
e320f86b
authored
1月 13, 2016
作者:
William King
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-8728 Adding logging profile and functionality
上级
c01a8849
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
499 行增加
和
12 行删除
+499
-12
Makefile.am
src/mod/event_handlers/mod_amqp/Makefile.am
+1
-1
mod_amqp.c
src/mod/event_handlers/mod_amqp/mod_amqp.c
+11
-0
mod_amqp.h
src/mod/event_handlers/mod_amqp/mod_amqp.h
+35
-0
mod_amqp_logging.c
src/mod/event_handlers/mod_amqp/mod_amqp_logging.c
+416
-0
mod_amqp_producer.c
src/mod/event_handlers/mod_amqp/mod_amqp_producer.c
+4
-11
mod_amqp_utils.c
src/mod/event_handlers/mod_amqp/mod_amqp_utils.c
+32
-0
没有找到文件。
src/mod/event_handlers/mod_amqp/Makefile.am
浏览文件 @
e320f86b
...
...
@@ -4,7 +4,7 @@ MODNAME=mod_amqp
if
HAVE_AMQP
mod_LTLIBRARIES
=
mod_amqp.la
mod_amqp_la_SOURCES
=
mod_amqp_utils.c mod_amqp_connection.c mod_amqp_producer.c mod_amqp_command.c mod_amqp.c
mod_amqp_la_SOURCES
=
mod_amqp_utils.c mod_amqp_connection.c mod_amqp_producer.c mod_amqp_command.c mod_amqp
_logging.c mod_amqp
.c
mod_amqp_la_CFLAGS
=
$(AM_CFLAGS)
$(AMQP_CFLAGS)
mod_amqp_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
mod_amqp_la_LDFLAGS
=
-avoid-version
-module
-no-undefined
-shared
$(AMQP_LIBS)
$(SWITCH_AM_LDFLAGS)
...
...
src/mod/event_handlers/mod_amqp/mod_amqp.c
浏览文件 @
e320f86b
...
...
@@ -62,6 +62,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amqp_load)
globals
.
pool
=
pool
;
switch_core_hash_init
(
&
(
globals
.
producer_hash
));
switch_core_hash_init
(
&
(
globals
.
command_hash
));
switch_core_hash_init
(
&
(
globals
.
logging_hash
));
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"mod_apqp loading: Version %s
\n
"
,
switch_version_full
());
...
...
@@ -72,6 +73,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amqp_load)
SWITCH_ADD_API
(
api_interface
,
"amqp"
,
"amqp API"
,
amqp_reload
,
"syntax"
);
switch_log_bind_logger
(
mod_amqp_logging_recv
,
SWITCH_LOG_DEBUG
,
SWITCH_FALSE
);
return
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -84,6 +87,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_amqp_shutdown)
switch_hash_index_t
*
hi
;
mod_amqp_producer_profile_t
*
producer
;
mod_amqp_command_profile_t
*
command
;
mod_amqp_logging_profile_t
*
logging
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Mod starting shutting down
\n
"
);
switch_event_unbind_callback
(
mod_amqp_producer_event_handler
);
...
...
@@ -98,6 +102,13 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_amqp_shutdown)
mod_amqp_command_destroy
(
&
command
);
}
switch_log_unbind_logger
(
mod_amqp_logging_recv
);
while
((
hi
=
switch_core_hash_first
(
globals
.
logging_hash
)))
{
switch_core_hash_this
(
hi
,
NULL
,
NULL
,
(
void
**
)
&
logging
);
mod_amqp_logging_destroy
(
&
logging
);
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Mod finished shutting down
\n
"
);
return
SWITCH_STATUS_SUCCESS
;
}
...
...
src/mod/event_handlers/mod_amqp/mod_amqp.h
浏览文件 @
e320f86b
...
...
@@ -146,17 +146,46 @@ typedef struct {
char
*
custom_attr
;
}
mod_amqp_command_profile_t
;
typedef
struct
{
char
*
name
;
char
*
exchange
;
char
*
exchange_type
;
int
exchange_durable
;
int
exchange_auto_delete
;
uint32_t
log_level_mask
;
/* Note: The AMQP channel is not reentrant this MUTEX serializes sending events. */
mod_amqp_connection_t
*
conn_root
;
mod_amqp_connection_t
*
conn_active
;
int
reconnect_interval_ms
;
/* Logging thread */
switch_thread_t
*
logging_thread
;
switch_queue_t
*
send_queue
;
unsigned
int
send_queue_size
;
switch_mutex_t
*
mutex
;
switch_bool_t
running
;
char
*
custom_attr
;
switch_memory_pool_t
*
pool
;
}
mod_amqp_logging_profile_t
;
struct
{
switch_memory_pool_t
*
pool
;
switch_hash_t
*
producer_hash
;
switch_hash_t
*
command_hash
;
switch_hash_t
*
logging_hash
;
}
globals
;
/* utils */
switch_status_t
mod_amqp_do_config
(
switch_bool_t
reload
);
int
mod_amqp_log_if_amqp_error
(
amqp_rpc_reply_t
x
,
char
const
*
context
);
int
mod_amqp_count_chars
(
const
char
*
string
,
char
ch
);
void
mod_amqp_util_msg_destroy
(
mod_amqp_message_t
**
msg
);
/* connection */
switch_status_t
mod_amqp_connection_create
(
mod_amqp_connection_t
**
conn
,
switch_xml_t
cfg
,
switch_memory_pool_t
*
pool
);
...
...
@@ -179,5 +208,11 @@ void * SWITCH_THREAD_FUNC mod_amqp_producer_thread(switch_thread_t *thread, void
char
*
amqp_util_encode
(
char
*
key
,
char
*
dest
);
/* logging */
switch_status_t
mod_amqp_logging_recv
(
const
switch_log_node_t
*
node
,
switch_log_level_t
level
);
switch_status_t
mod_amqp_logging_create
(
char
*
name
,
switch_xml_t
cfg
);
switch_status_t
mod_amqp_logging_destroy
(
mod_amqp_logging_profile_t
**
prof
);
void
*
SWITCH_THREAD_FUNC
mod_amqp_logging_thread
(
switch_thread_t
*
thread
,
void
*
data
);
#endif
/* MOD_AMQP_H */
src/mod/event_handlers/mod_amqp/mod_amqp_logging.c
0 → 100644
浏览文件 @
e320f86b
差异被折叠。
点击展开。
src/mod/event_handlers/mod_amqp/mod_amqp_producer.c
浏览文件 @
e320f86b
...
...
@@ -38,13 +38,6 @@
#include "mod_amqp.h"
void
mod_amqp_producer_msg_destroy
(
mod_amqp_message_t
**
msg
)
{
if
(
!
msg
||
!*
msg
)
return
;
switch_safe_free
((
*
msg
)
->
pjson
);
switch_safe_free
(
*
msg
);
}
switch_status_t
mod_amqp_producer_routing_key
(
mod_amqp_producer_profile_t
*
profile
,
char
routingKey
[
MAX_AMQP_ROUTING_KEY_LENGTH
],
switch_event_t
*
evt
,
mod_amqp_keypart_t
routingKeyEventHeaderNames
[])
{
...
...
@@ -115,7 +108,7 @@ void mod_amqp_producer_event_handler(switch_event_t* evt)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"AMQP message queue full. Messages will be dropped for %.1fs! (Queue capacity %d)"
,
profile
->
circuit_breaker_ms
/
1000
.
0
,
queue_size
);
mod_amqp_
producer
_msg_destroy
(
&
amqp_message
);
mod_amqp_
util
_msg_destroy
(
&
amqp_message
);
}
}
...
...
@@ -155,7 +148,7 @@ switch_status_t mod_amqp_producer_destroy(mod_amqp_producer_profile_t **prof) {
profile
->
conn_root
=
NULL
;
while
(
profile
->
send_queue
&&
switch_queue_trypop
(
profile
->
send_queue
,
(
void
**
)
&
msg
)
==
SWITCH_STATUS_SUCCESS
)
{
mod_amqp_
producer
_msg_destroy
(
&
msg
);
mod_amqp_
util
_msg_destroy
(
&
msg
);
}
if
(
pool
)
{
...
...
@@ -497,7 +490,7 @@ void * SWITCH_THREAD_FUNC mod_amqp_producer_thread(switch_thread_t *thread, void
switch
(
mod_amqp_producer_send
(
profile
,
msg
))
{
case
SWITCH_STATUS_SUCCESS
:
/* Success: prepare for next message */
mod_amqp_
producer
_msg_destroy
(
&
msg
);
mod_amqp_
util
_msg_destroy
(
&
msg
);
break
;
case
SWITCH_STATUS_NOT_INITALIZED
:
...
...
@@ -541,7 +534,7 @@ void * SWITCH_THREAD_FUNC mod_amqp_producer_thread(switch_thread_t *thread, void
}
/* Abort the current message */
mod_amqp_
producer
_msg_destroy
(
&
msg
);
mod_amqp_
util
_msg_destroy
(
&
msg
);
// Terminate the thread
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Event sender thread stopped
\n
"
);
...
...
src/mod/event_handlers/mod_amqp/mod_amqp_utils.c
浏览文件 @
e320f86b
...
...
@@ -144,6 +144,30 @@ switch_status_t mod_amqp_do_config(switch_bool_t reload)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Unable to locate commands section for mod_amqp
\n
"
);
}
if
((
profiles
=
switch_xml_child
(
cfg
,
"logging"
)))
{
if
((
profile
=
switch_xml_child
(
profiles
,
"profile"
)))
{
for
(;
profile
;
profile
=
profile
->
next
)
{
char
*
name
=
(
char
*
)
switch_xml_attr_soft
(
profile
,
"name"
);
if
(
zstr
(
name
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to load mod_amqp profile. Check configs missing name attr
\n
"
);
continue
;
}
name
=
switch_core_strdup
(
globals
.
pool
,
name
);
if
(
mod_amqp_logging_create
(
name
,
profile
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to load mod_amqp profile [%s]. Check configs
\n
"
,
name
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Loaded mod_amqp profile [%s] successfully
\n
"
,
name
);
}
}
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Unable to locate a profile for mod_amqp
\n
"
);
}
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Unable to locate logging section for mod_amqp
\n
"
);
}
return
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -183,6 +207,14 @@ char *amqp_util_encode(char *key, char *dest) {
return
dest
;
}
void
mod_amqp_util_msg_destroy
(
mod_amqp_message_t
**
msg
)
{
if
(
!
msg
||
!*
msg
)
return
;
switch_safe_free
((
*
msg
)
->
pjson
);
switch_safe_free
(
*
msg
);
}
/* For Emacs:
* Local Variables:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论