Commit e1078720 authored by Hardy Simpson's avatar Hardy Simpson

feature: more complex rotate support(in progress)

parent 612831f2
......@@ -15,8 +15,9 @@
[ ] 减少dynamic文件名open的次数,通过日期改变智能推断, file_table?
--- 1.2.0 ---
[ ] fstat64
[ ] rotate和zip的方案
[o] 把一部分static变量化为全局变量,减少接口参数
[o] fstat64
[o] pipe, cronolog
[o] record忽略第二参数
[o] __VA_ARGS__的跨平台
......@@ -24,7 +25,9 @@
[o] 去除auto tools的使用,自行makefile[redis]
[o] 宏都小写化
[o] const
[x] zlog_set("section", "command");
[x] 每线程内置rule-> file fd write time
[x] 用时间作为判断重载配置reload conf period,而不是次数,需要每次取时间计算,暂不考虑
[x] zlog_set_conf("section", "command");
[x] format,spec,level采用直接数组的方式重写,性能提高不大
[x] 增加manpage, df, 案例
--- 1.1.3 ---
......
......@@ -1514,7 +1514,7 @@ zlog_info(c, "hello, zlog");
<lyxtabular version="3" rows="21" columns="3">
<features islongtable="true" longtabularalignment="center">
<column alignment="center" valignment="top" width="10text%">
<column alignment="center" valignment="top" width="50text%">
<column alignment="left" valignment="top" width="50text%">
<column alignment="center" valignment="top" width="40text%">
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
......@@ -1526,7 +1526,7 @@ zlog_info(c, "hello, zlog");
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1555,7 +1555,7 @@ zlog_info(c, "hello, zlog");
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1584,12 +1584,12 @@ aa_bb
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
打日志的时间。这个后面要跟一对小括号()内含说明具体的日期格式。就像%d(%F)或者%d(%m-%d %T)。如果不跟小括号,默认是%d(%F
%T)。括号内的格式和 strftime(3)的格式一致。详见
%T)。括号内的格式和 strftime(2)的格式一致。详见
\begin_inset CommandInset ref
LatexCommand ref
reference "sub:时间字符"
......@@ -1633,7 +1633,7 @@ reference "sub:时间字符"
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1662,7 +1662,7 @@ reference "sub:时间字符"
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1695,7 +1695,7 @@ reference "sub:时间字符"
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1728,11 +1728,11 @@ reference "sub:时间字符"
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
源代码文件名,来源于__FILE__宏。在某些编译器下 __FILE__是绝对路径。用$f来去掉目录只保留文件名,或者编译器有选项可以调节
源代码文件名,来源于__FILE__宏。在某些编译器下 __FILE__是绝对路径。用%f来去掉目录只保留文件名,或者编译器有选项可以调节
\end_layout
\end_inset
......@@ -1765,7 +1765,7 @@ test_hello.c
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1794,7 +1794,7 @@ test_hello.c
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1823,7 +1823,7 @@ zlog-dev
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1852,7 +1852,7 @@ zlog-dev
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1881,7 +1881,7 @@ hello, zlog
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1918,7 +1918,7 @@ reference "sec:MDC"
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1949,7 +1949,7 @@ n
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -1978,7 +1978,7 @@ n
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -2007,7 +2007,7 @@ main
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -2036,7 +2036,7 @@ INFO
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -2065,7 +2065,7 @@ info
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -2098,7 +2098,7 @@ info
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -2131,7 +2131,7 @@ info
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -2160,7 +2160,7 @@ info
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
......@@ -2206,7 +2206,7 @@ info
\begin_layout Standard
这种行为可以用最大字段宽度来改变。最大字段宽度是放在一个句点号(.)后面的十进制数字常量。如果数据的宽度超过了最大字段宽度,则尾部多余的字符(超过最大字段宽度的部
分)将会被截去。 最大字段宽度是8,数据的宽度是10,则最后两个字符会被丢弃。假如这种行为和C的printf是一样的,把后面的部分截断。
分)将会被截去。 最大字段宽度是8,数据的宽度是10,则最后两个字符会被丢弃。这种行为和C的printf是一样的,把后面的部分截断。
\end_layout
\begin_layout Standard
......@@ -4493,15 +4493,15 @@ $ time ./test_press_zlog 1 10 100000
\end_layout
\begin_layout LyX-Code
real 0m9.234s
real 0m4.240s
\end_layout
\begin_layout LyX-Code
user 0m2.860s
user 0m2.500s
\end_layout
\begin_layout LyX-Code
sys 0m10.060s
sys 0m5.460s
\end_layout
\begin_layout LyX-Code
......
......@@ -1748,7 +1748,7 @@ Used to output the date of the logging event.
enclosed between parenthesis.
For example, %d(%F) or %d(%m-%d %T).
If no date format specifier is given then %d(%F %T) format is assumed.
The date format specifier admits the same syntax as the strftime(3).
The date format specifier admits the same syntax as the strftime(2).
see
\begin_inset CommandInset ref
LatexCommand ref
......@@ -1895,7 +1895,7 @@ comes from gettimeofday(2)
Used to output the file name where the logging request was issued.
The file name comes from __FILE__ macro.
Some compiler take __FILE__ as the absolute path.
Use $f to strip path and remain file name.
Use %f to strip path and remain file name.
Or complier has option to switch.
\end_layout
......@@ -4758,15 +4758,15 @@ $ time ./test_press_zlog 1 10 100000
\end_layout
\begin_layout LyX-Code
real 0m9.234s
real 0m4.240s
\end_layout
\begin_layout LyX-Code
user 0m2.860s
user 0m2.500s
\end_layout
\begin_layout LyX-Code
sys 0m10.060s
sys 0m5.460s
\end_layout
\begin_layout LyX-Code
......
......@@ -22,7 +22,11 @@ normal = "%d(%F %T.%l) %m%n"
[rules]
default.* >stdout; simple
*.* -"%12.2E(HOME)/log/%c.log", 1MB*12; simple
*.* -"%12.2E(HOME)/log/%c.log", \
1MB * 12 ~ "%E(HOME)/log/%c.%D(%F) #2r #3s.log"; \
simple
my_.INFO >stderr;
my_cat.!ERROR "/var/log/aa.log"
my_dog.=DEBUG >syslog, LOG_LOCAL0; simple
......
......@@ -187,7 +187,7 @@ static int zlog_conf_build_without_file(zlog_conf_t * a_conf)
{
zlog_rule_t *default_rule;
a_conf->default_format = zlog_format_new(a_conf->default_format_line, a_conf->levels);
a_conf->default_format = zlog_format_new(a_conf->default_format_line);
if (!a_conf->default_format) {
zc_error("zlog_format_new fail");
return -1;
......@@ -201,8 +201,6 @@ static int zlog_conf_build_without_file(zlog_conf_t * a_conf)
default_rule = zlog_rule_new(
ZLOG_CONF_DEFAULT_RULE,
a_conf->rotater,
a_conf->levels,
a_conf->default_format,
a_conf->formats,
a_conf->file_perms,
......@@ -386,7 +384,7 @@ static int zlog_conf_parse_line(zlog_conf_t * a_conf, char *line, int *section)
return -1;
}
a_conf->default_format = zlog_format_new(a_conf->default_format_line, a_conf->levels);
a_conf->default_format = zlog_format_new(a_conf->default_format_line);
if (!a_conf->default_format) {
zc_error("zlog_format_new fail");
return -1;
......@@ -454,7 +452,7 @@ static int zlog_conf_parse_line(zlog_conf_t * a_conf, char *line, int *section)
}
break;
case 3:
a_format = zlog_format_new(line, a_conf->levels);
a_format = zlog_format_new(line);
if (!a_format) {
zc_error("zlog_format_new fail [%s]", line);
if (a_conf->strict_init) return -1;
......@@ -468,8 +466,6 @@ static int zlog_conf_parse_line(zlog_conf_t * a_conf, char *line, int *section)
break;
case 4:
a_rule = zlog_rule_new(line,
a_conf->rotater,
a_conf->levels,
a_conf->default_format,
a_conf->formats,
a_conf->file_perms,
......
......@@ -47,6 +47,8 @@ typedef struct zlog_conf_s {
zc_arraylist_t *rules;
} zlog_conf_t;
extern zlog_conf_t * zlog_env_conf;
zlog_conf_t *zlog_conf_new(const char *confpath);
void zlog_conf_del(zlog_conf_t * a_conf);
void zlog_conf_profile(zlog_conf_t * a_conf, int flag);
......
......@@ -60,7 +60,7 @@ void zlog_format_del(zlog_format_t * a_format)
return;
}
zlog_format_t *zlog_format_new(char *line, zc_arraylist_t *levels)
zlog_format_t *zlog_format_new(char *line)
{
int nscan = 0;
zlog_format_t *a_format = NULL;
......@@ -72,7 +72,6 @@ zlog_format_t *zlog_format_new(char *line, zc_arraylist_t *levels)
zlog_spec_t *a_spec;
zc_assert(line, NULL);
zc_assert(levels, NULL);
a_format = calloc(1, sizeof(zlog_format_t));
if (!a_format) {
......@@ -130,7 +129,7 @@ zlog_format_t *zlog_format_new(char *line, zc_arraylist_t *levels)
}
for (p = a_format->pattern; *p != '\0'; p = q) {
a_spec = zlog_spec_new(p, &q, levels);
a_spec = zlog_spec_new(p, &q);
if (!a_spec) {
zc_error("zlog_spec_new fail");
goto err;
......
......@@ -31,7 +31,7 @@ struct zlog_format_s {
zc_arraylist_t *pattern_specs;
};
zlog_format_t *zlog_format_new(char *line, zc_arraylist_t *levels);
zlog_format_t *zlog_format_new(char *line);
void zlog_format_del(zlog_format_t * a_format);
void zlog_format_profile(zlog_format_t * a_format, int flag);
......
This diff is collapsed.
......@@ -22,21 +22,36 @@
#include "zc_defs.h"
typedef struct zlog_rotater_s zlog_rotater_t;
typedef struct zlog_rotater_s {
pthread_mutex_t lock_mutex;
char *lock_file;
int lock_fd;
/* single-use members */
char *base_path; /* aa.log */
char *archive_path; /* aa.#5i.log */
char glob_path[MAXLEN_PATH + 1]; /* aa.*.log */
size_t num_start_len; /* 3 offset to archive_path */
size_t num_end_len; /* 6 offset to archive_path */
int num_width; /* 5 */
int mv_type; /* ROLLING or SEQUENCE */
int max_count;
zc_arraylist_t files;
} zlog_rotater_t;
zlog_rotater_t *zlog_rotater_new(char *lock_file);
void zlog_rotater_del(zlog_rotater_t *a_rot);
void zlog_rotater_del(zlog_rotater_t *a_rotater);
/*
* return
* -1 fail
* 0 no rotate
* 1 rotate and success
* 0 no rotate, or rotate and success
*/
int zlog_rotater_rotate(zlog_rotater_t *a_rot,
char *file_path, long file_max_size, int file_max_count,
size_t msg_len);
int zlog_rotater_rotate(zlog_rotater_t *a_rotater,
const char *base_path, size_t msg_len,
const char *archive_path, long archive_max_size, int archive_max_count,
int *reopen_fd, int reopen_flags, unsigned int reopen_perms);
void zlog_rotater_profile(zlog_rotater_t *a_rot, int flag);
void zlog_rotater_profile(zlog_rotater_t *a_rotater, int flag);
#endif
This diff is collapsed.
......@@ -50,15 +50,17 @@ struct zlog_rule_s {
int level;
unsigned char level_bitmap[32]; /* for category determine whether ouput or not */
unsigned int file_perms;
int file_open_flags;
char file_path[MAXLEN_PATH + 1];
zc_arraylist_t *dynamic_file_specs;
int static_file_descriptor;
pthread_rwlock_t static_reopen_lock;
unsigned int file_perms;
int file_open_flags;
long file_max_size;
int file_max_count;
long archive_max_size;
int archive_max_count;
char archive_path[MAXLEN_PATH + 1];
zc_arraylist_t *archive_specs;
FILE *pipe_fp;
int pipe_fd;
......@@ -70,8 +72,6 @@ struct zlog_rule_s {
int syslog_facility;
zlog_format_t *format;
zlog_rotater_t *rotater;
zlog_rule_output_fn output;
char record_name[MAXLEN_PATH + 1];
......@@ -80,8 +80,6 @@ struct zlog_rule_s {
};
zlog_rule_t *zlog_rule_new(char *line,
zlog_rotater_t * a_rotater,
zc_arraylist_t * levels,
zlog_format_t * default_format,
zc_arraylist_t * formats,
unsigned int file_perms,
......
......@@ -29,10 +29,12 @@
#include <sys/types.h>
#include <unistd.h>
#include "conf.h"
#include "spec.h"
#include "level_list.h"
#include "zc_defs.h"
#define ZLOG_DEFAULT_TIME_FMT "%F %T"
#define ZLOG_HEX_HEAD \
"\n 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"
......@@ -236,7 +238,7 @@ static int zlog_spec_write_level_lowercase(zlog_spec_t * a_spec, zlog_thread_t *
{
zlog_level_t *a_level;
a_level = zlog_level_list_get(a_spec->levels, a_thread->event->level);
a_level = zlog_level_list_get(zlog_env_conf->levels, a_thread->event->level);
return zlog_buf_append(a_buf, a_level->str_lowercase, a_level->str_len);
}
......@@ -244,7 +246,7 @@ static int zlog_spec_write_level_uppercase(zlog_spec_t * a_spec, zlog_thread_t *
{
zlog_level_t *a_level;
a_level = zlog_level_list_get(a_spec->levels, a_thread->event->level);
a_level = zlog_level_list_get(zlog_env_conf->levels, a_thread->event->level);
return zlog_buf_append(a_buf, a_level->str_uppercase, a_level->str_len);
}
......@@ -398,6 +400,32 @@ static int zlog_spec_gen_path_reformat(zlog_spec_t * a_spec, zlog_thread_t * a_t
a_spec->left_adjust, a_spec->min_width, a_spec->max_width);
}
/*******************************************************************************/
static int zlog_spec_gen_archive_path_direct(zlog_spec_t * a_spec, zlog_thread_t * a_thread)
{
/* no need to reprint %1.2d here */
return a_spec->write_buf(a_spec, a_thread, a_thread->archive_path_buf);
}
static int zlog_spec_gen_archive_path_reformat(zlog_spec_t * a_spec, zlog_thread_t * a_thread)
{
int rc;
zlog_buf_restart(a_thread->pre_path_buf);
rc = a_spec->write_buf(a_spec, a_thread, a_thread->pre_path_buf);
if (rc < 0) {
zc_error("a_spec->gen_buf fail");
return -1;
} else if (rc > 0) {
/* buf is full, try printf */
}
return zlog_buf_adjust_append(a_thread->archive_path_buf,
zlog_buf_str(a_thread->pre_path_buf), zlog_buf_len(a_thread->pre_path_buf),
a_spec->left_adjust, a_spec->min_width, a_spec->max_width);
}
/*******************************************************************************/
static int zlog_spec_parse_print_fmt(zlog_spec_t * a_spec)
{
......@@ -435,7 +463,7 @@ void zlog_spec_del(zlog_spec_t * a_spec)
* a const string: /home/bb
* a string begin with %: %12.35d(%F %X,%l)
*/
zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, zc_arraylist_t *levels)
zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next)
{
char *p;
int nscan = 0;
......@@ -444,7 +472,6 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, zc_arraylis
zc_assert(pattern_start, NULL);
zc_assert(pattern_next, NULL);
zc_assert(levels, NULL);
a_spec = calloc(1, sizeof(zlog_spec_t));
if (!a_spec) {
......@@ -452,7 +479,6 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, zc_arraylis
return NULL;
}
a_spec->levels = levels;
a_spec->str = p = pattern_start;
switch (*p) {
......@@ -464,6 +490,7 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, zc_arraylis
if (nscan == 1) {
a_spec->gen_msg = zlog_spec_gen_msg_reformat;
a_spec->gen_path = zlog_spec_gen_path_reformat;
a_spec->gen_archive_path = zlog_spec_gen_archive_path_reformat;
if (zlog_spec_parse_print_fmt(a_spec)) {
zc_error("zlog_spec_parse_print_fmt fail");
goto err;
......@@ -472,6 +499,7 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, zc_arraylis
nread = 1; /* skip the % char */
a_spec->gen_msg = zlog_spec_gen_msg_direct;
a_spec->gen_path = zlog_spec_gen_path_direct;
a_spec->gen_archive_path = zlog_spec_gen_archive_path_direct;
}
p += nread;
......@@ -605,6 +633,7 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, zc_arraylis
a_spec->write_buf = zlog_spec_write_str;
a_spec->gen_msg = zlog_spec_gen_msg_direct;
a_spec->gen_path = zlog_spec_gen_path_direct;
a_spec->gen_archive_path = zlog_spec_gen_archive_path_direct;
}
zlog_spec_profile(a_spec, ZC_DEBUG);
......
......@@ -47,14 +47,12 @@ struct zlog_spec_s {
size_t max_width;
size_t min_width;
zc_arraylist_t *levels;
zlog_spec_write_fn write_buf;
zlog_spec_gen_fn gen_msg;
zlog_spec_gen_fn gen_path;
};
zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_end, zc_arraylist_t *levels);
zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_end);
void zlog_spec_del(zlog_spec_t * a_spec);
void zlog_spec_profile(zlog_spec_t * a_spec, int flag);
......@@ -64,4 +62,7 @@ void zlog_spec_profile(zlog_spec_t * a_spec, int flag);
#define zlog_spec_gen_path(a_spec, a_thread) \
a_spec->gen_path(a_spec, a_thread)
#define zlog_spec_gen_archive_path(a_spec, a_thread) \
a_spec->gen_archive_path(a_spec, a_thread)
#endif
......@@ -29,12 +29,13 @@
void zlog_thread_profile(zlog_thread_t * a_thread, int flag)
{
zc_assert(a_thread,);
zc_profile(flag, "--thread[%p][%p][%p][%p,%p,%p,%p]--",
zc_profile(flag, "--thread[%p][%p][%p][%p,%p,%p,%p,%p]--",
a_thread,
a_thread->mdc,
a_thread->event,
a_thread->pre_path_buf,
a_thread->path_buf,
a_thread->archive_path_buf,
a_thread->pre_msg_buf,
a_thread->msg_buf);
......@@ -42,6 +43,7 @@ void zlog_thread_profile(zlog_thread_t * a_thread, int flag)
zlog_event_profile(a_thread->event, flag);
zlog_buf_profile(a_thread->pre_path_buf, flag);
zlog_buf_profile(a_thread->path_buf, flag);
zlog_buf_profile(a_thread->archive_path_buf, flag);
zlog_buf_profile(a_thread->pre_msg_buf, flag);
zlog_buf_profile(a_thread->msg_buf, flag);
return;
......@@ -58,6 +60,8 @@ void zlog_thread_del(zlog_thread_t * a_thread)
zlog_buf_del(a_thread->pre_path_buf);
if (a_thread->path_buf)
zlog_buf_del(a_thread->path_buf);
if (a_thread->archive_path_buf)
zlog_buf_del(a_thread->archive_path_buf);
if (a_thread->pre_msg_buf)
zlog_buf_del(a_thread->pre_msg_buf);
if (a_thread->msg_buf)
......@@ -102,6 +106,12 @@ zlog_thread_t *zlog_thread_new(size_t buf_size_min, size_t buf_size_max)
goto err;
}
a_thread->archive_path_buf = zlog_buf_new(MAXLEN_PATH + 1, MAXLEN_PATH + 1, NULL);
if (!a_thread->archive_path_buf) {
zc_error("zlog_buf_new fail");
goto err;
}
a_thread->pre_msg_buf = zlog_buf_new(buf_size_min, buf_size_max, "..." FILE_NEWLINE);
if (!a_thread->pre_msg_buf) {
zc_error("zlog_buf_new fail");
......
......@@ -31,6 +31,7 @@ typedef struct {
zlog_buf_t *pre_path_buf;
zlog_buf_t *path_buf;
zlog_buf_t *archive_path_buf;
zlog_buf_t *pre_msg_buf;
zlog_buf_t *msg_buf;
......
......@@ -87,7 +87,7 @@ size_t zc_parse_byte_size(char *astring)
}
/*******************************************************************************/
int zc_str_replace_env(char *str, size_t size)
int zc_str_replace_env(char *str, size_t str_size)
{
char *p;
char *q;
......@@ -137,9 +137,7 @@ int zc_str_replace_env(char *str, size_t size)
return -1;
}
env_value_len =
snprintf(env_value, sizeof(env_value), fmt,
getenv(env_key));
env_value_len = snprintf(env_value, sizeof(env_value), fmt, getenv(env_key));