Commit b9acd868 authored by Hardy Simpson's avatar Hardy Simpson

feature: new style of config file is done!

parent 940299b6
......@@ -5,6 +5,7 @@
[x] 修改arraylist的读取长度,循环等
[x] 运行期间指定是否采用线程
[x] buf_append 优化——为了安全,不优化这个
[x] 用某种自动编译器以及文档生成器
[o] 研究ilog读配置文件, buf
[o] 采用更加面向对象的方法来写
[o] 使用arraylist来代替linklist为内部数据结构
......@@ -35,14 +36,13 @@
[o] ylog, 更简单的接口, 改名为dzlog的一堆接口来解决
[o] zlog-gen-conf
[o] rotate控制个数
[o] 改变配置文件的布局,去掉@ &这种符号,改用[global],[format]这样的形式来
[o] 把reload改成原子性的,失败用旧的
[o] 优化spec_gen_msg部分, spec内采用自己写的buf_append对齐来代替buf_sprintf
[p] 使用valgrind测试性能
[p] 用某种自动编译器以及文档生成器
[p] 改变配置文件的布局,去掉@ &这种符号,改用[global],[format]这样的形式来
[ ] 把reload改成原子性的,失败用旧的
[ ] 文件的权限设置
[ ] 输出函数自定义
[ ] spec内采用自己写的buf_append对齐来代替buf_sprintf
[ ] 增加man age, df, 案例, doxygen
[ ] zlog-chk-conf -c
[ ] zlog-input -c category -p priority -f conf
......
AC_PREREQ(2.59)
AC_INIT([zlog], [0.9.1], [HardySimpson1984@gmail.com])
AC_INIT([zlog], [1.0.0], [HardySimpson1984@gmail.com])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_CONFIG_SRCDIR([libzlog/zlog.h])
AC_CONFIG_HEADER([config.h])
......
......@@ -2,4 +2,4 @@
# from configure,Makefile.am->Makefile, developer use
CFLAGS="-Wall -Werror" ./configure --prefix=/opt/develop/ --enable-test
CFLAGS="-Wall -Werror -g -O1" ./configure --prefix=/opt/develop/ --enable-test
......@@ -2488,6 +2488,14 @@ reference "sub:Time-Character"
test_hello.c
\end_layout
\begin_layout Plain Layout
或者在某些编译器下
\end_layout
\begin_layout Plain Layout
/home/zlog/src/test/test_hello.c
\end_layout
\end_inset
</cell>
</row>
......@@ -5469,9 +5477,16 @@ $ ./test_mdc
\end_layout
\begin_layout LyX-Code
2012-03-12 09:26:37.740 INFO (my_cat:test_mdc.c:47) [] - 1.hello, zlog 2012-03-12
09:26:37.740 INFO (my_cat:test_mdc.c:51) [Zhang] - 2.hello, zlog 2012-03-12
09:26:37.740 INFO (my_cat:test_mdc.c:55) [Li] - 3.hello, zlog
2012-03-12 09:26:37.740 INFO (my_cat:test_mdc.c:47) [] - 1.hello, zlog
\end_layout
\begin_layout LyX-Code
2012-03-12 09:26:37.740 INFO (my_cat:test_mdc.c:51) [Zhang] - 2.hello, zlog
\end_layout
\begin_layout LyX-Code
2012-03-12 09:26:37.740 INFO (my_cat:test_mdc.c:55) [Li] - 3.hello, zlog
\end_layout
\begin_layout Standard
......
......@@ -2585,6 +2585,14 @@ Used to output the file name where the logging request was issued.
test_hello.c
\end_layout
\begin_layout Plain Layout
or, under some compiler
\end_layout
\begin_layout Plain Layout
/home/zlog/src/test/test_hello.c
\end_layout
\end_inset
</cell>
</row>
......
......@@ -3,7 +3,7 @@ strict init = true
buffer min = 1024
buffer max = 2MB
rotate lock file = /tmp/zlog.lock
default format = "%d(%F %X.%l) %-6P (%c:%F:%L) - %m%n"
default format = "%d(%F %T.%l) %-6P (%c:%F:%L) - %m%n"
[levels]
TRACE = 10, LOG_ERR
......
This diff is collapsed.
......@@ -21,14 +21,16 @@
#define __zlog_buf_h
#include <stdarg.h>
#include <time.h>
typedef struct zlog_buf_s {
size_t size_min;
size_t size_max;
size_t size_step;
size_t size_real;
char truncate_str[MAXLEN_PATH + 1];
size_t truncate_str_len;
size_t size_real;
char *start;
char *end;
} zlog_buf_t;
......@@ -45,4 +47,7 @@ int zlog_buf_append(zlog_buf_t * a_buf, const char *str, size_t str_len);
int zlog_buf_strftime(zlog_buf_t * a_buf, const char *time_fmt, size_t time_len,
const struct tm *a_tm);
int zlog_buf_adjust_append(zlog_buf_t * a_buf, const char *str, size_t str_len,
int left_adjust, size_t min_width, size_t max_width);
#endif
......@@ -34,9 +34,9 @@ void zlog_category_profile(zlog_category_t *a_category, int flag)
zc_profile(flag, "--category[%p][%s][%p]--",
a_category,
a_category->name,
a_category->match_rules);
if (a_category->match_rules) {
zc_arraylist_foreach(a_category->match_rules, i, a_rule) {
a_category->fit_rules);
if (a_category->fit_rules) {
zc_arraylist_foreach(a_category->fit_rules, i, a_rule) {
zlog_rule_profile(a_rule, flag);
}
}
......@@ -47,7 +47,7 @@ void zlog_category_profile(zlog_category_t *a_category, int flag)
void zlog_category_del(zlog_category_t * a_category)
{
zc_assert(a_category,);
if (a_category->match_rules) zc_arraylist_del(a_category->match_rules);
if (a_category->fit_rules) zc_arraylist_del(a_category->fit_rules);
free(a_category);
zc_debug("zlog_category_del[%p]", a_category);
return;
......@@ -69,34 +69,34 @@ static int zlog_category_set_name(zlog_category_t * a_category, char *name)
return 0;
}
int zlog_category_obtain_rules(zlog_category_t * a_category, zc_arraylist_t * rules)
static int zlog_category_obtain_rules(zlog_category_t * a_category, zc_arraylist_t * rules)
{
int i;
int count = 0;
int rc = 0;
int match = 0;
int fit = 0;
zlog_rule_t *a_rule;
zlog_rule_t *wastebin_rule = NULL;
if (a_category->match_rules) {
/* before set, clean last match rules first */
zc_arraylist_del(a_category->match_rules);
if (a_category->fit_rules) {
/* before set, clean last fit rules first */
zc_arraylist_del(a_category->fit_rules);
}
a_category->match_rules = zc_arraylist_new(NULL);
if (!(a_category->match_rules)) {
a_category->fit_rules = zc_arraylist_new(NULL);
if (!(a_category->fit_rules)) {
zc_error("zc_arraylist_new fail");
return -1;
}
/* get match rules from all rules */
zc_arraylist_foreach(rules, i, a_rule) {
match = zlog_rule_match_category(a_rule, a_category->name);
if (match) {
rc = zc_arraylist_add(a_category->match_rules, a_rule);
fit = zlog_rule_match_category(a_rule, a_category->name);
if (fit) {
rc = zc_arraylist_add(a_category->fit_rules, a_rule);
if (rc) {
zc_error("zc_arrylist_add fail");
goto zlog_category_match_rules_exit;
goto zlog_category_obtain_rules_exit;
}
count++;
}
......@@ -109,10 +109,10 @@ int zlog_category_obtain_rules(zlog_category_t * a_category, zc_arraylist_t * ru
if (count == 0) {
if (wastebin_rule) {
zc_debug("category[%s], no match rules, use wastebin_rule", a_category->name);
rc = zc_arraylist_add(a_category->match_rules, wastebin_rule);
rc = zc_arraylist_add(a_category->fit_rules, wastebin_rule);
if (rc) {
zc_error("zc_arrylist_add fail");
goto zlog_category_match_rules_exit;
goto zlog_category_obtain_rules_exit;
}
count++;
} else {
......@@ -120,10 +120,10 @@ int zlog_category_obtain_rules(zlog_category_t * a_category, zc_arraylist_t * ru
}
}
zlog_category_match_rules_exit:
zlog_category_obtain_rules_exit:
if (rc) {
zc_arraylist_del(a_category->match_rules);
a_category->match_rules = NULL;
zc_arraylist_del(a_category->fit_rules);
a_category->fit_rules = NULL;
return -1;
} else {
return 0;
......@@ -136,6 +136,7 @@ zlog_category_t *zlog_category_new(char *name, zc_arraylist_t * rules)
zlog_category_t *a_category;
zc_assert(name, NULL);
zc_assert(rules, NULL);
a_category = calloc(1, sizeof(zlog_category_t));
if (!a_category) {
......@@ -149,9 +150,9 @@ zlog_category_t *zlog_category_new(char *name, zc_arraylist_t * rules)
goto zlog_category_new_exit;
}
rc = zlog_category_match_rules(a_category, rules);
rc = zlog_category_obtain_rules(a_category, rules);
if (rc) {
zc_error("zlog_category_match_rules fail");
zc_error("zlog_category_fit_rules fail");
goto zlog_category_new_exit;
}
......@@ -164,6 +165,73 @@ zlog_category_t *zlog_category_new(char *name, zc_arraylist_t * rules)
return a_category;
}
}
/*******************************************************************************/
/* update success: fit_rules 1, fit_rules_backup 1 */
/* update fail: fit_rules 0, fit_rules_backup 1 */
int zlog_category_update_rules(zlog_category_t * a_category, zc_arraylist_t * new_rules)
{
int rc = 0;
zc_assert(a_category, -1);
zc_assert(new_rules, -1);
/* 1st, mv fit_rules fit_rules_backup */
if (a_category->fit_rules_backup) zc_arraylist_del(a_category->fit_rules_backup);
a_category->fit_rules_backup = a_category->fit_rules;
a_category->fit_rules = NULL;
/* 2nd, obtain new_rules to fit_rules */
rc = zlog_category_obtain_rules(a_category, new_rules);
if (rc) {
zc_error("zlog_category_obtain_rules fail");
a_category->fit_rules = NULL;
return -1;
}
/* keep the fit_rules_backup not change, return */
return 0;
}
/* commit fail: fit_rules_backup != 0 */
/* commit success: fit_rules 1, fit_rules_backup 0 */
void zlog_category_commit_rules(zlog_category_t * a_category)
{
zc_assert(a_category,);
if (!a_category->fit_rules_backup) {
zc_warn("a_category->fit_rules_backup is NULL, never update before");
return;
}
zc_arraylist_del(a_category->fit_rules_backup);
a_category->fit_rules_backup = NULL;
return;
}
/* rollback fail: fit_rules_backup != 0 */
/* rollback success: fit_rules 1, fit_rules_backup 0 */
/* so whether update succes or not, make things back to old */
void zlog_category_rollback_rules(zlog_category_t * a_category)
{
zc_assert(a_category,);
if (!a_category->fit_rules_backup) {
zc_warn("a_category->fit_rules_backup in NULL, never update before");
return;
}
if (a_category->fit_rules) {
/* update success, rm new and backup */
zc_arraylist_del(a_category->fit_rules);
a_category->fit_rules = a_category->fit_rules_backup;
a_category->fit_rules_backup = NULL;
} else {
/* update fail, just backup */
a_category->fit_rules = a_category->fit_rules_backup;
a_category->fit_rules_backup = NULL;
}
return; /* always success */
}
/*******************************************************************************/
int zlog_category_output(zlog_category_t * a_category, zlog_thread_t * a_thread)
{
......@@ -173,7 +241,7 @@ int zlog_category_output(zlog_category_t * a_category, zlog_thread_t * a_thread)
zlog_rule_t *a_rule;
/* go through all match rules to output */
zc_arraylist_foreach(a_category->match_rules, i, a_rule) {
zc_arraylist_foreach(a_category->fit_rules, i, a_rule) {
rc = zlog_rule_output(a_rule, a_thread);
if (rc) {
zc_error("hzb_log_rule_output fail");
......
......@@ -26,14 +26,19 @@
typedef struct zlog_category_s {
char name[MAXLEN_PATH + 1];
size_t name_len;
zc_arraylist_t *match_rules;
zc_arraylist_t *fit_rules;
zc_arraylist_t *fit_rules_backup;
} zlog_category_t;
zlog_category_t *zlog_category_new(char *name, zc_arraylist_t * rules);
void zlog_category_del(zlog_category_t * a_category);
void zlog_category_profile(zlog_category_t *a_category, int flag);
int zlog_category_update_rules(zlog_category_t * a_category, zc_arraylist_t * new_rules);
void zlog_category_commit_rules(zlog_category_t * a_category);
void zlog_category_rollback_rules(zlog_category_t * a_category);
int zlog_category_output(zlog_category_t * a_cat, zlog_thread_t * a_thread);
int zlog_category_obtain_rules(zlog_category_t * a_category, zc_arraylist_t * rules);
#endif
......@@ -65,26 +65,50 @@ zc_hashtable_t *zlog_category_table_new(void)
}
}
/*******************************************************************************/
int zlog_category_table_obtain_rules(
zc_hashtable_t * categories,
zc_arraylist_t * rules)
int zlog_category_table_update_rules(zc_hashtable_t * categories, zc_arraylist_t * new_rules)
{
int rc;
int rc = 0;
zc_hashtable_entry_t *a_entry;
zlog_category_t *a_category;
zc_assert(categories, -1);
zc_hashtable_foreach(categories, a_entry) {
a_category = (zlog_category_t *) a_entry->value;
rc = zlog_category_obtain_rules(a_category, rules);
rc = zlog_category_update_rules(a_category, new_rules);
if (rc) {
zc_error("zlog_category_obtain_rules fail");
zc_error("zlog_category_update_rules fail, try rollback");
return -1;
}
}
return 0;
}
void zlog_category_table_commit_rules(zc_hashtable_t * categories)
{
zc_hashtable_entry_t *a_entry;
zlog_category_t *a_category;
zc_assert(categories,);
zc_hashtable_foreach(categories, a_entry) {
a_category = (zlog_category_t *) a_entry->value;
zlog_category_commit_rules(a_category);
}
return;
}
void zlog_category_table_rollback_rules(zc_hashtable_t * categories)
{
zc_hashtable_entry_t *a_entry;
zlog_category_t *a_category;
zc_assert(categories,);
zc_hashtable_foreach(categories, a_entry) {
a_category = (zlog_category_t *) a_entry->value;
zlog_category_rollback_rules(a_category);
}
return;
}
/*******************************************************************************/
zlog_category_t *zlog_category_table_fetch_category(
zc_hashtable_t * categories,
......
......@@ -27,13 +27,14 @@ zc_hashtable_t *zlog_category_table_new(void);
void zlog_category_table_del(zc_hashtable_t * categories);
void zlog_category_table_profile(zc_hashtable_t * categories, int flag);
int zlog_category_table_obtain_rules(
zc_hashtable_t * categories,
zc_arraylist_t * rules);
/* if none, create new and return */
zlog_category_t *zlog_category_table_fetch_category(
zc_hashtable_t * categories,
char *category_name, zc_arraylist_t * rules);
int zlog_category_table_update_rules(zc_hashtable_t * categories, zc_arraylist_t * new_rules);
void zlog_category_table_commit_rules(zc_hashtable_t * categories);
void zlog_category_table_rollback_rules(zc_hashtable_t * categories);
#endif
This diff is collapsed.
......@@ -29,4 +29,9 @@ zlog_conf_t *zlog_conf_new(char *conf_file);
void zlog_conf_del(zlog_conf_t * a_conf);
void zlog_conf_profile(zlog_conf_t * a_conf, int flag);
zc_arraylist_t *zlog_conf_get_rules(zlog_conf_t *a_conf);
void zlog_conf_get_buf_size(zlog_conf_t *a_conf,
size_t * buf_size_min, size_t * buf_size_max);
char *zlog_conf_get_file(zlog_conf_t *a_conf);
#endif
......@@ -91,7 +91,7 @@ zlog_event_t *zlog_event_new(void)
}
/*******************************************************************************/
void zlog_event_refresh(zlog_event_t * a_event,
void zlog_event_set(zlog_event_t * a_event,
char *category_name, size_t * category_name_len,
char *file, long line, int level,
void *hex_buf, size_t hex_buf_len, char *str_format,
......@@ -123,8 +123,9 @@ void zlog_event_refresh(zlog_event_t * a_event,
/* pid should fetch eveytime, as no one knows,
* when does user fork his process
* so clean here, and fetch at spec.c
*/
a_event->pid = getpid();
a_event->pid = (pid_t) 0;
/* in a event's life cycle, time will be get when spec need,
* and keep unchange though all life cycle
......
......@@ -60,7 +60,7 @@ zlog_event_t *zlog_event_new(void);
void zlog_event_del(zlog_event_t * a_event);
void zlog_event_profile(zlog_event_t * a_event, int flag);
void zlog_event_refresh(zlog_event_t * a_event,
void zlog_event_set(zlog_event_t * a_event,
char *category_name, size_t * category_name_len,
char *file, long line, int level,
void *hex_buf, size_t hex_buf_len, char *str_format,
......
......@@ -22,6 +22,7 @@
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "zc_defs.h"
#include "thread.h"
......@@ -70,7 +71,7 @@ zlog_format_t *zlog_format_new(char *line, zc_arraylist_t *levels)
int rc = 0;
int nscan = 0;
zlog_format_t *a_format = NULL;
int nread;
int nread = 0;
const char *p_start;
const char *p_end;
char *p;
......@@ -91,13 +92,19 @@ zlog_format_t *zlog_format_new(char *line, zc_arraylist_t *levels)
* pattern %d(%F %X.%l) %-6V (%c:%F:%L) - %m%n
*/
memset(a_format->name, 0x00, sizeof(a_format->name));
nscan = sscanf(line, " %[^= ] = %n", a_format->name, &nread);
nscan = sscanf(line, " %[^= \t] = %n", a_format->name, &nread);
if (nscan != 1) {
zc_error("format[%s], syntax wrong", line);
rc = -1;
goto zlog_format_new_exit;
}
if (*(line + nread) != '"') {
zc_error("the 1st char of pattern is not \", line+nread[%s]", line+nread);
rc = -1;
goto zlog_format_new_exit;
}
for (p = a_format->name; *p != '\0'; p++) {
if ((!isalnum(*p)) && (*p != '_')) {
zc_error("a_format->name[%s] character is not in [a-Z][0-9][_]",
......@@ -107,11 +114,6 @@ zlog_format_t *zlog_format_new(char *line, zc_arraylist_t *levels)
}
}
if (*(line + nread) != '"') {
zc_error("the 1st char of pattern is not \", line[%s]", line);
rc = -1;
goto zlog_format_new_exit;
}
p_start = line + nread + 1;
p_end = strrchr(p_start, '"');
......@@ -179,11 +181,12 @@ int zlog_format_gen_msg(zlog_format_t * a_format, zlog_thread_t * a_thread)
zc_arraylist_foreach(a_format->pattern_specs, i, a_spec) {
rc = zlog_spec_gen_msg(a_spec, a_thread);
if (rc < 0) {
switch (rc) {
case -1:
zc_error("zlog_spec_gen_msg fail");
return -1;
} else if (rc > 0) {
/* buf is full */
case 1:
zc_error("zlog_spec_gen_msg, buffer is full");
break;
}
}
......
......@@ -52,7 +52,7 @@ static int syslog_level_atoi(char *str)
/* guess no unix system will choose -187
* as its syslog level, so it is a safe return value
*/
zc_assert_debug(str, -187);
zc_assert(str, -187);
if (STRICMP(str, ==, "LOG_EMERG"))
return LOG_EMERG;
......@@ -78,17 +78,20 @@ static int syslog_level_atoi(char *str)
/* line: TRACE = 10, LOG_ERR */
zlog_level_t *zlog_level_new(char *line)
{
int rc;
zlog_level_t *a_level;
int rc = 0;
zlog_level_t *a_level = NULL;
int i;
int nscan;
char str[MAXLEN_CFG_LINE + 1];
int l;
int l = 0;
char sl[MAXLEN_CFG_LINE + 1];
zc_assert(line, NULL);
nscan = sscanf(line, " %[^= ] = %d ,%s",
memset(str, 0x00, sizeof(str));
memset(sl, 0x00, sizeof(sl));
nscan = sscanf(line, " %[^= \t] = %d ,%s",
str, &l, sl);
if (nscan < 2) {
zc_error("level[%s], syntax wrong", line);
......@@ -101,12 +104,12 @@ zlog_level_t *zlog_level_new(char *line)
return NULL;
}
if (*str == '\0') {
if (str[0] == '\0') {
zc_error("str[0] = 0");
return NULL;
}
a_level = calloc(1, sizeof(*a_level));
a_level = calloc(1, sizeof(zlog_level_t));
if (!a_level) {
zc_error("calloc fail, errno[%d]", errno);
return NULL;
......@@ -115,7 +118,7 @@ zlog_level_t *zlog_level_new(char *line)
a_level->int_level = l;
/* fill syslog level */
if (*sl == '\0') {
if (sl[0] == '\0') {
a_level->syslog_level = LOG_DEBUG;
} else {
a_level->syslog_level = syslog_level_atoi(sl);
......
......@@ -36,7 +36,8 @@ void zlog_level_list_profile(zc_arraylist_t *levels, int flag)
zc_assert(levels,);
zc_profile(flag, "--level_list[%p]--", levels);
zc_arraylist_foreach(levels, i, a_level) {
zc_level_profile(a_level, flag);
/* skip empty slots */
if (a_level) zlog_level_profile(a_level, flag);
}
return;
}
......@@ -46,7 +47,7 @@ void zlog_level_list_del(zc_arraylist_t *levels)
{
zc_assert(levels,);
zc_arraylist_del(levels);
zc_debug("zc_levels_del[%p]", levels);
zc_debug("zc_level_list_del[%p]", levels);
return;
}
......@@ -65,7 +66,7 @@ static int zlog_level_list_set_default(zc_arraylist_t *levels)
zc_arraylist_t *zlog_level_list_new(void)
{
int rc;
int rc = 0;
zc_arraylist_t *levels;
levels = zc_arraylist_new((zc_arraylist_del_fn)zlog_level_del);
......@@ -74,7 +75,7 @@ zc_arraylist_t *zlog_level_list_new(void)
return NULL;
}
rc = zlog_levels_set_default(levels);
rc = zlog_level_list_set_default(levels);
if (rc) {
zc_error("zlog_level_set_default fail");
rc = -1;
......@@ -86,7 +87,7 @@ zc_arraylist_t *zlog_level_list_new(void)
zc_arraylist_del(levels);
return NULL;
} else {
zlog_levels_profile(levels, ZC_DEBUG);
zlog_level_list_profile(levels, ZC_DEBUG);
return levels;
}
}
......@@ -94,7 +95,7 @@ zc_arraylist_t *zlog_level_list_new(void)
/*******************************************************************************/
int zlog_level_list_set(zc_arraylist_t *levels, char *line)
{
int rc;
int rc = 0;
zlog_level_t *a_level;
a_level = zlog_level_new(line);
......@@ -107,10 +108,10 @@ int zlog_level_list_set(zc_arraylist_t *levels, char *line)
if (rc) {
zc_error("zc_arraylist_set fail");
rc = -1;
goto zlog_level_set_exit;
goto zlog_level_list_set_exit;
}
zlog_level_set_exit:
zlog_level_list_set_exit:
if (rc) {
zc_error("line[%s]", line);
zlog_level_del(a_level);
......
all_o = zlog.o category.o rule.o format.o event.o conf.o level.o buf.o rotater.o spec.o process.o \
zc_hashtable.o zc_error.o zc_arraylist.o zc_xplatform.o zc_util.o \
all_o = \
buf.o \
category.o \
category_table.o \
conf.o \
event.o \
format.o \
level.o \
level_list.o \
mdc.o \
rotater.o \
rule.o \
spec.o \
thread.o \
thread_table.o \
zc_arraylist.o \
zc_hashtable.o \
zc_profile.o \
zc_util.o \
zc_xplatform.o \
zlog.o \
all : libzlog.a zlog_chk_conf
all : libzlog.a
libzlog.a : $(all_o)
ar -rv $@ $(all_o)
zlog_chk_conf : zlog_chk_conf.o
gcc -o $@ $^ -L. -lzlog -lpthread
ctags -R .
.c.o :
gcc -pg -Wall -D_GNU_SOURCE -o $@ -c $< -I.
......
......@@ -33,7 +33,7 @@ void zlog_mdc_profile(zlog_mdc_t *a_mdc, int flag)
zlog_mdc_kv_t *a_mdc_kv;
zc_assert(a_mdc,);
zlog_profile(flag, "---mdc[%p]---", a_mdc);
zc_profile(flag, "---mdc[%p]---", a_mdc);
zc_hashtable_foreach(a_mdc->tab, a_entry) {
a_mdc_kv = a_entry->value;
......
......@@ -232,8 +232,7 @@ static int zlog_rotater_trylock(zlog_rotater_t *a_rotater)
rc = pthread_mutex_trylock(&(a_rotater->lock_mutex));
if (rc) {
if (errno == EBUSY) {
zc_debug
("pthread_mutex_trylock fail, as lock_mutex is locked by other threads");
zc_warn("pthread_mutex_trylock fail, as lock_mutex is locked by other threads");
} else {
zc_error("pthread_mutex_trylock fail, errno[%d]",
errno);
......@@ -247,8 +246,7 @@ static int zlog_rotater_trylock(zlog_rotater_t *a_rotater)
/* lock by other process, that's right, go on */
/* EAGAIN on linux */
/* EACCES on AIX */
zc_debug
("fcntl lock fail, as file is lock by other process");
zc_warn("fcntl lock fail, as file is lock by other process");
} else {
zc_error("lock fd[%d] fail, errno[%d]", a_rotater->lock_fd,
errno);
......@@ -442,7 +440,7 @@ int zlog_rotater_rotate(zlog_rotater_t *a_rotater,
int rd = 0;
struct stat info;
zc_assert_debug(file_path, -1);
zc_assert(file_path, -1);
if (msg_len > file_max_size) {
zc_debug("one msg's len[%ld] > file_max_size[%ld], no rotate",
......@@ -463,7 +461,7 @@ int zlog_rotater_rotate(zlog_rotater_t *a_rotater,
rd = zlog_rotater_trylock(a_rotater);
if (rd) {
zc_error("warn:zlog_rotater_trylock fail, maybe lock by other process or threads");
zc_warn("zlog_rotater_trylock fail, maybe lock by other process or threads");