Commit 21b77e39 authored by Hardy Simpson's avatar Hardy Simpson

doc: UsersGuide-EN.lyx is done, others not. Writing doc is more tired than coding!

parent 6691ac1e
......@@ -58,6 +58,7 @@
[ ] hzlog的可定制话
[ ] 分类匹配的可定制化
[ ] 兼容性问题
zlog.h内,__VA_ARGS__的跨平台
==========
编写文章:
......
......@@ -2,4 +2,4 @@
# from configure,Makefile.am->Makefile, developer use
CFLAGS="-Wall -Werror -g -O2" ./configure --prefix=/opt/develop/ --enable-test
CFLAGS="-Wall -Werror -g -O2 -std=c99" ./configure --prefix=/opt/develop/ --enable-test
......@@ -158,7 +158,7 @@ syslog风格的配置文件,易学易用
\end_layout
\begin_layout Itemize
纲目分类模型,比log4j系列的继承模型更加清晰
syslog分类模型,比log4j系列的继承模型更加清晰
\end_layout
\begin_layout Itemize
......@@ -205,7 +205,7 @@ MDC,一个log4j风格的键-值对的表,可以扩展用户自定义的字
\end_layout
\begin_layout Itemize
不依赖其他库,只要是个POSIX系统就成
不依赖其他库,只要是个POSIX系统就成(当然还要一个C99兼容的vsnprintf)
\end_layout
\begin_layout Standard
......@@ -291,6 +291,44 @@ type "mailto:"
\end_layout
\begin_layout Section
zlog 1.0 发布说明
\end_layout
\begin_layout Enumerate
zlog是基于POSIX的。目前我手上有的环境只有AIX和linux。如果在其他的系统下(FreeBSD, NetBSD, OpenBSD, OpenSolar
is, Mac OS X...)有问题欢迎探讨
\end_layout
\begin_layout Enumerate
zlog使用了一个C99兼容的vsnprintf。也就是说如果缓存大小不足,vsnprintf将会返回目标字符串应有的长度(不包括'
\backslash
0')。如果在你的系统上vsnprintf不是这么运作的,zlog就不知道怎么扩大缓存。如果在目标缓存不够的时候vsnprintf返回-1,zlog就会认为这次
写入失败。幸运的是目前大多数c标准库符合C99标准。glibc 2.1,libc on AIX, libc on freebsd...都是好的,不过glibc2.0不是。
在这种情况下,用户需要自己来装一个C99兼容的vsnprintf,来crack这个函数库。我推荐
\begin_inset CommandInset href
LatexCommand href
name "ctrio"
target "http://sourceforge.net/projects/ctrio/"
\end_inset
, 或者
\begin_inset CommandInset href
LatexCommand href
name "C99-snprintf"
target "http://www.jhweiss.de/software/snprintf.html"
\end_inset
。只要改buf.c就行,祝好运!
\end_layout
\begin_layout Enumerate
zlog1.0和0.9不是兼容的。因为我增加了__func__,这样在C99情况下能打印函数名。我还改了配置文件的格式,对配置文件分节,这样看的清楚点。如果你是zl
og0.9的用户,想要升级到1.0,那就需要重新编译你的程序链接新的库(你的源代码倒不用改,因为几个输出日志的宏和0.9还是一样)
\end_layout
\begin_layout Chapter
zlog不是什么?
\end_layout
......
This diff is collapsed.
......@@ -3,8 +3,8 @@ strict init = true
buffer min = 1024
buffer max = 2MB
rotate lock file = /tmp/zlog.lock
default format = "%d(%F %T.%l) %-6P (%c:%F:%L) - %m%n"
file mode = 600
default format = "%d(%F %T.%l) %-6V (%c:%F:%L) - %m%n"
file perms = 600
[levels]
TRACE = 10
......
......@@ -34,6 +34,7 @@
* So, what should you do if you want to using zlog on the platform that doesn't
* conform C99? My Answer is, crack zlog with a portable C99-vsnprintf, like this
* http://sourceforge.net/projects/ctrio/
* http://www.jhweiss.de/software/snprintf.html
* If you can see this note, you can fix it yourself? Aren't you? ^_^
* Oh, I put the snprintf in C99 standard here,
......
......@@ -31,10 +31,12 @@
void zlog_event_profile(zlog_event_t * a_event, int flag)
{
zc_assert(a_event,);
zc_profile(flag, "---event[%p][%s,%s][%s,%ld][%p,%s][%ld,%ld][%ld,%ld]---",
zc_profile(flag, "---event[%p][%s,%s][%s(%ld),%s(%ld),%ld,%d][%p,%s][%ld,%ld][%ld,%ld]---",
a_event,
a_event->category_name, a_event->host_name,
a_event->file, a_event->line,
a_event->file, a_event->file_len,
a_event->func, a_event->func_len,
a_event->line, a_event->level,
a_event->hex_buf, a_event->str_format,
a_event->time_stamp.tv_sec, a_event->time_stamp.tv_usec,
(long)a_event->pid, (long)a_event->tid);
......
......@@ -656,7 +656,7 @@ zlog_rule_t *zlog_rule_new(char *line,
goto zlog_rule_new_exit;
}
} else {
printf("the 1st char[%c] of file_path[%s] is wrong",
zc_error("the 1st char[%c] of file_path[%s] is wrong",
file_path[0], file_path);
rc = -1;
goto zlog_rule_new_exit;
......
......@@ -75,13 +75,53 @@ typedef enum {
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# define inline
# define register
# if __GNUC__ >= 2 || _MSC_VER >= 1300
# if defined __GNUC__ && __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
#endif
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
/* zlog macros */
#define ZLOG_FATAL(cat, format, ...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_FATAL, format, ## __VA_ARGS__)
#define ZLOG_ERROR(cat, format, ...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_ERROR, format, ## __VA_ARGS__)
#define ZLOG_WARN(cat, format, ...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_WARN, format, ## __VA_ARGS__)
#define ZLOG_NOTICE(cat, format, ...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_NOTICE, format, ## __VA_ARGS__)
#define ZLOG_INFO(cat, format, ...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_INFO, format, ## __VA_ARGS__)
#define ZLOG_DEBUG(cat, format, ...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_DEBUG, format, ## __VA_ARGS__)
/* dzlog macros */
#define DZLOG_FATAL(format, ...) \
ddzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_FATAL, format, ## __VA_ARGS__)
#define DZLOG_ERROR(format, ...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_ERROR, format, ## __VA_ARGS__)
#define DZLOG_WARN(format, ...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_WARN, format, ## __VA_ARGS__)
#define DZLOG_NOTICE(format, ...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_NOTICE, format, ## __VA_ARGS__)
#define DZLOG_INFO(format, ...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_INFO, format, ## __VA_ARGS__)
#define DZLOG_DEBUG(format, ...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_DEBUG, format, ## __VA_ARGS__)
#elif defined __GNUC__
/* zlog macros */
#define ZLOG_FATAL(cat, format, args...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
......@@ -96,11 +136,31 @@ typedef enum {
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_NOTICE, format, ##args)
#define ZLOG_INFO(cat, format, args...) \
zlog(cat, __FILE__, sizeof(__FILE__), __func__, sizeof(__func__), __LINE__, \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_INFO, format, ##args)
#define ZLOG_DEBUG(cat, format, args...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_DEBUG, format, ##args)
/* dzlog macros */
#define DZLOG_FATAL(format, args...) \
ddzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_FATAL, format, ##args)
#define DZLOG_ERROR(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_ERROR, format, ##args)
#define DZLOG_WARN(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_WARN, format, ##args)
#define DZLOG_NOTICE(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_NOTICE, format, ##args)
#define DZLOG_INFO(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_INFO, format, ##args)
#define DZLOG_DEBUG(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_DEBUG, format, ##args)
#endif
/* vzlog macros */
#define VZLOG_FATAL(cat, format, args) \
......@@ -142,25 +202,6 @@ typedef enum {
hzlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_DEBUG, buf, buf_len)
/* dzlog macros */
#define DZLOG_FATAL(format, args...) \
ddzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_FATAL, format, ##args)
#define DZLOG_ERROR(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_ERROR, format, ##args)
#define DZLOG_WARN(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_WARN, format, ##args)
#define DZLOG_NOTICE(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_NOTICE, format, ##args)
#define DZLOG_INFO(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_INFO, format, ##args)
#define DZLOG_DEBUG(format, args...) \
dzlog(__FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_DEBUG, format, ##args)
/* vdzlog macros */
#define VDZLOG_FATAL(format, args) \
......
[global]
strict init = true
buffer min = 1024
buffer max = 0
rotate lock file = /tmp/zlog.lock
[formats]
simple = "%m%n"
[rules ]
[rules]
my_cat.* >stdout;simple
my_cat.* >stdout;
......@@ -39,6 +39,7 @@ int main(int argc, char** argv)
}
ZLOG_INFO(zc, "hello, zlog");
zlog_profile();
zlog_fini();
......
bin_PROGRAMS = zlog-chk-conf zlog-gen-conf
bin_PROGRAMS = zlog-chk-conf
zlog_chk_conf_SOURCES = zlog-chk-conf.c
zlog_gen_conf_SOURCES = zlog-gen-conf.c
LDADD = \
$(top_builddir)/libzlog/libzlog.la \
$(PTREADLIB)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment