Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
2d4e159b
提交
2d4e159b
authored
12月 18, 2011
作者:
Marc Olivier Chouinard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3763 --resolve
上级
7987d046
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
63 行增加
和
0 行删除
+63
-0
logfile.conf.xml
conf/autoload_configs/logfile.conf.xml
+3
-0
mod_logfile.c
src/mod/loggers/mod_logfile/mod_logfile.c
+60
-0
没有找到文件。
conf/autoload_configs/logfile.conf.xml
浏览文件 @
2d4e159b
...
...
@@ -10,6 +10,9 @@
<!--<param name="logfile" value="/var/log/freeswitch.log"/>-->
<!-- At this length in bytes rotate the log file (0 for never) -->
<param
name=
"rollover"
value=
"10485760"
/>
<!-- Maximum number of log files to keep before wrapping -->
<!-- If this parameter is enabled, the log filenames will not include a date stamp -->
<!-- <param name="maximum-rotate" value="32"/> -->
<!-- Uncomment to prefix all log lines by the session's uuid -->
<!-- <param name="uuid" value="true" /> -->
</settings>
...
...
src/mod/loggers/mod_logfile/mod_logfile.c
浏览文件 @
2d4e159b
...
...
@@ -53,10 +53,12 @@ struct logfile_profile {
char
*
name
;
switch_size_t
log_size
;
/* keep the log size in check for rotation */
switch_size_t
roll_size
;
/* the size that we want to rotate the file at */
switch_size_t
max_rot
;
/* number of log files to keep within the rotation */
char
*
logfile
;
switch_file_t
*
log_afd
;
switch_hash_t
*
log_hash
;
uint32_t
all_level
;
uint32_t
suffix
;
/* suffix of the highest logfile name */
switch_bool_t
log_uuid
;
};
...
...
@@ -140,6 +142,58 @@ static switch_status_t mod_logfile_rotate(logfile_profile_t *profile)
switch_core_new_memory_pool
(
&
pool
);
filename
=
switch_core_alloc
(
pool
,
strlen
(
profile
->
logfile
)
+
WARM_FUZZY_OFFSET
);
if
(
profile
->
max_rot
)
{
char
*
from_filename
=
NULL
;
char
*
to_filename
=
NULL
;
from_filename
=
switch_core_alloc
(
pool
,
strlen
(
profile
->
logfile
)
+
WARM_FUZZY_OFFSET
);
to_filename
=
switch_core_alloc
(
pool
,
strlen
(
profile
->
logfile
)
+
WARM_FUZZY_OFFSET
);
for
(
i
=
profile
->
suffix
;
i
>
1
;
i
--
)
{
sprintf
((
char
*
)
to_filename
,
"%s.%i"
,
profile
->
logfile
,
i
);
sprintf
((
char
*
)
from_filename
,
"%s.%i"
,
profile
->
logfile
,
i
-
1
);
if
(
switch_file_exists
(
to_filename
,
pool
)
==
SWITCH_STATUS_SUCCESS
)
{
if
((
status
=
switch_file_remove
(
to_filename
,
pool
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Error removing log %s
\n
"
,
to_filename
);
goto
end
;
}
}
if
((
status
=
switch_file_rename
(
from_filename
,
to_filename
,
pool
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Error renaming log from %s to %s
\n
"
,
from_filename
,
to_filename
);
goto
end
;
}
}
sprintf
((
char
*
)
to_filename
,
"%s.%i"
,
profile
->
logfile
,
i
);
if
(
switch_file_exists
(
to_filename
,
pool
)
==
SWITCH_STATUS_SUCCESS
)
{
if
((
status
=
switch_file_remove
(
to_filename
,
pool
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Error removing log %s
\n
"
,
to_filename
);
goto
end
;
}
}
switch_file_close
(
profile
->
log_afd
);
if
((
status
=
switch_file_rename
(
profile
->
logfile
,
to_filename
,
pool
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Error renaming log from %s to %s
\n
"
,
profile
->
logfile
,
to_filename
);
goto
end
;
}
if
((
status
=
mod_logfile_openlogfile
(
profile
,
SWITCH_FALSE
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Error reopening log %s
\n
"
,
profile
->
logfile
);
}
if
(
profile
->
suffix
<
profile
->
max_rot
)
{
profile
->
suffix
++
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"New log started.
\n
"
);
goto
end
;
}
/* XXX This have no real value EXCEPT making sure if we rotate within the same second, the end index will increase */
for
(
i
=
1
;
i
<
MAX_ROT
;
i
++
)
{
sprintf
((
char
*
)
filename
,
"%s.%s.%i"
,
profile
->
logfile
,
date
,
i
);
if
(
switch_file_exists
(
filename
,
pool
)
==
SWITCH_STATUS_SUCCESS
)
{
...
...
@@ -269,6 +323,7 @@ static switch_status_t load_profile(switch_xml_t xml)
switch_core_hash_init
(
&
(
new_profile
->
log_hash
),
module_pool
);
new_profile
->
name
=
switch_core_strdup
(
module_pool
,
switch_str_nil
(
name
));
new_profile
->
suffix
=
1
;
if
((
settings
=
switch_xml_child
(
xml
,
"settings"
)))
{
for
(
param
=
switch_xml_child
(
settings
,
"param"
);
param
;
param
=
param
->
next
)
{
...
...
@@ -281,6 +336,11 @@ static switch_status_t load_profile(switch_xml_t xml)
if
(
new_profile
->
roll_size
<
0
)
{
new_profile
->
roll_size
=
0
;
}
}
else
if
(
!
strcmp
(
var
,
"maximum-rotate"
))
{
new_profile
->
max_rot
=
atoi
(
val
);
if
(
new_profile
->
max_rot
<
0
)
{
new_profile
->
max_rot
=
MAX_ROT
;
}
}
else
if
(
!
strcmp
(
var
,
"uuid"
)
&&
switch_true
(
val
))
{
new_profile
->
log_uuid
=
SWITCH_TRUE
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论