Commit ac3e3560 authored by Hardy Simpson's avatar Hardy Simpson

doc: for 1.0 version

parent 6019c612
SUBDIRS = \
libzlog \
tools
tools \
doc
if ENABLE_TEST
SUBDIRS += test
......@@ -11,8 +12,4 @@ pkgconfig_DATA = zlog.pc
EXTRA_DIST = \
autogen.sh \
zlog.pc.in \
doc/UsersGuide-CN.pdf \
doc/UsersGuide-EN.pdf \
doc/GettingStart-CN.txt \
doc/GettingStart-EN.txt
zlog.pc.in
......@@ -6,6 +6,9 @@
[x] 运行期间指定是否采用线程
[x] buf_append 优化——为了安全,不优化这个
[x] 用某种自动编译器以及文档生成器
[x] 输出到管道,有名管道和文件一样
[x] 打印堆栈。。可能需要语言支持
[x] zlog-input -c category -p priority -f conf
[o] 研究ilog读配置文件, buf
[o] 采用更加面向对象的方法来写
[o] 使用arraylist来代替linklist为内部数据结构
......@@ -41,20 +44,15 @@
[o] 优化spec_gen_msg部分, spec内采用自己写的buf_append对齐来代替buf_sprintf
[o] 引入__func__
[o] 文件的权限设置
[o] 输出函数自定义
[p] 使用valgrind测试性能
[ ] 输出函数自定义
[ ] 增加man age, df, 案例, doxygen
[ ] zlog-chk-conf -c
[ ] zlog-input -c category -p priority -f conf
[ ] 输出到管道
[ ] 配置n个线程的内存,在一开始申请,减少开线程的时候的消耗
[ ] 增加man age, df, 案例
[ ] 和rsyslog对接的问题
[ ] 采用精细的reo en方法来建立用fo en来智能判断需不需要重开文件
[ ]需要建立全局FILE hashtable及计数器
[ ] 自动刷新配置....同上
[ ] 测试多线程的效率
[ ] 打印堆栈。。可能需要语言支持
[ ] hzlog的可定制话
[ ] 分类匹配的可定制化
[ ] 兼容性问题
......
......@@ -59,6 +59,7 @@ Makefile
libzlog/Makefile
tools/Makefile
test/Makefile
doc/Makefile
])
AC_OUTPUT
......@@ -18,6 +18,13 @@ $ make
$ sudo make install
# 默认安装在/usr/local/下,包括libzlog.so和zlog.h
# add one line
$ sudo vi /etc/ld.so.conf
/usr/local/lib
$ sudo ldconfig
在你的程序运行之前,保证libzlog.so在系统的动态链接库加载器可以找到的目录下。上面的命令适用于linux,别的系统自己想办法。
2.介绍一下配置文件
......@@ -32,8 +39,10 @@ zlog里面有三个重要的概念,category,format,rule
现在试着写配置文件,配置文件名无所谓,放在哪里也无所谓,反正在zlog_init()的时候可以指定
$ cat /etc/zlog.conf
&simple "%m%n"
my_cat.DEBUG >stdout; simple
[formats]
simple = "%m%n"
[rules]
my_cat.DEBUG >stdout; simple
在目前的配置文件的例子里面,可以看到my_cat分类,>=debug等级的日志会被输出到stdout(标准输出),并且输出的格式是simple这个格式,也就是用户输入信息+换行符。如果要输出到文件并控制文件大小为1兆,规则的配置应该是
my_cat.DEBUG "/var/log/aa.log", 1M; simple
......@@ -78,24 +87,23 @@ $ ./test_hello
hello, zlog
5.高级使用
* syslog风格的配置文件,易学易用
* 可以灵活配置日志输出的格式,类似于log4j的pattern layout
* 纲目分类模型,比log4j系列的继承模型更加清晰
* 多种输出,包括动态文件、静态文件、stdout、stderr、syslog
* 可以在运行时动态刷新配置,只需要调用函数zlog_reload()
* 高性能,在我的笔记本上达到72'000条日志每秒, 大概是syslog(3)配合rsyslogd的200倍速度
* 用户可以自定义等级,无需改变库代码
* 多线程和多进程写同一个日志的情况下,安全转档(转档就是把太大的日志重命名)
* 可以精确到微秒
* 如果一个程序默认只用一个分类输出,zlog提供了简单的调用包装dzlog
* MDC,一个log4j风格的键-值对的表,可以扩展用户自定义的字段
* 自诊断,可以在运行时输出zlog自己的日志和配置状态
* 不依赖其他库,只要是个POSIX系统就成
* syslog分类模型,比log4j模型更加直接了当
* 日志格式定制,类似于log4j的pattern layout
* 多种输出,包括动态文件、静态文件、stdout、stderr、syslog、用户自定义输出函数
* 运行时刷新配置——调用函数zlog_reload()
* 高性能,在我的笔记本上达到72'000条日志每秒, 大概是syslog(3)配合rsyslogd的200倍速度
* 用户自定义等级
* 多线程和多进程环境下保证安全转档
* 精确到微秒
* 简单调用包装dzlog(一个程序默认只用一个分类)
* MDC,线程键-值对的表,可以扩展用户自定义的字段
* 自诊断,可以在运行时输出zlog自己的日志和配置状态
* 不依赖其他库,只要是个POSIX系统就成(当然还要一个C99兼容的vsnprintf)
6.相关链接
软件下载:https://github.com/downloads/HardySimpson/zlog/zlog-latest-stable.tar.gz
上手指南:zlog-latest-stable.tar.gz包内doc目录下 GettingStart-CN.txt GettingStart-EN.txt
使用攻略:zlog-latest-stable.tar.gz包内doc目录下 UsersGuide-CN.pdf UsersGuide-EN.pdf
上手指南:doc目录下 GettingStart-CN.txt GettingStart-EN.txt
使用攻略:doc目录下 UsersGuide-CN.pdf UsersGuide-EN.pdf
源代码:git@github.com:HardySimpson/zlog.git
英文主页:http://hardysimpson.github.com/zlog
中文主页:http://www.oschina.net/p/zlog
......
......@@ -13,12 +13,19 @@ Download https://github.com/downloads/HardySimpson/zlog/zlog-latest-stable.tar.g
uncompress, install
$ tar -zxvf zlog-latest-stable.tar.gz
$ cd zlog-0.9.0/
$ cd zlog-x.x.x/
$ ./configure --enable-test # complie test program
$ make
$ sudo make install
default install in /usr/local/, include libzlog.so and zlog.h
# add one line
$ sudo vi /etc/ld.so.conf
/usr/local/lib
$ sudo ldconfig
Before running a real program, make sure libzlog.so is in the directory where the system's dynamic lib loader can find it. The command metioned above is for linux. Other system should find its own way.
2. Introduce configure file
......@@ -33,8 +40,10 @@ Rule consists of category, level, output file(or other channel) and format. In b
Now write configure file. No matter what's the file name is or where it locates, zlog_init() will read file from agruments.
$ cat /etc/zlog.conf
&simple "%m%n"
my_cat.DEBUG >stdout; simple
[formats]
simple = "%m%n"
[rules]
my_cat.DEBUG >stdout; simple
In configure file now, you can see, logs, whose category of "my_cat", >= debug level, will be output to standard output, with the format of simple(%m - usermessage %n - newline).If you want output to a file and control its size, write like this
......@@ -80,26 +89,25 @@ $ ./test_hello
hello, zlog
5. Advance Using
* syslog style configure file, easy for understand and use
* log format Customization, like pattern layout in log4j
* range-category model, which is more flexible and more clear than hierarchy model of log4j
* multiple output, include static file path, dynamic file path, stdout, stderr, syslog
* runtime refreash configure to change output flow or output format, just need to call one function -- zlog_reload()
* high efficieny, on my laptop, record 720'000 log per second, about 200 times faster than syslog(3) with rsyslogd
* user can define his own log level without change and rebuild library
* safely rotate log file by size when multiple process or multiple threads write to one same log file
* accurate to microseconds
* dzlog, a default category log API for easy use
* MDC, a log4j style key-value map, expand user defined field in dynamic log file path or log format, is also useful in multi-thread programming
* self debugable, can output zlog's self debug&error log at runtime
* Not depend on any other 3rd party library, just base on POSIX system.
* syslog model, better than log4j model
* log format customization
* multiple output, include static file path, dynamic file path, stdout, stderr, syslog, user-defined ouput
* runtime refreash configure -- zlog_reload()
* high efficieny, about 200 times faster than syslog(3) with rsyslogd
* user-defined log level
* safely rotate log file on multiple-process or multiple-threads condition
* accurate to microseconds
* dzlog, a default category log API for easy use
* MDC, a log4j style key-value map
* self debugable, can output zlog's self debug&error log at runtime
* Not depend on any other 3rd party library, just base on POSIX system(and a C99 compliant vsnprintf).
6. Links:
Download: https://github.com/downloads/HardySimpson/zlog/zlog-latest-stable.tar.gz
GettingStart: in doc directory of zlog-0.9.0.tar.gz, GettingStart-CN.txt GettingStart-EN.txt
UsersGuide: in doc directory of zlog-0.9.0.tar.gz, UsersGuide-CN.pdf UsersGuide-EN.pdf
GettingStart: doc/GettingStart-CN.txt GettingStart-EN.txt
UsersGuide: doc/UsersGuide-CN.pdf UsersGuide-EN.pdf
Homepage(in English): http://hardysimpson.github.com/zlog
Homepage(in Chinese): http://www.oschina.net/p/zlog
Author's Blog(in Chinese): http://my.oschina.net/HardySimpson/blog
......
This diff is collapsed.
This diff is collapsed.
@ignore_error_format_rule false
@buf_size_min 1024
@buf_size_max 0
@rotate_lock_file /tmp/zlog.lock
&simple "%m%n"
[formats]
simple="%m%n"
[rules]
my_cat.* >stdout; simple
[global]
strict init = true
buffer min = 1024
buffer max = 0
rotate lock file = /tmp/zlog.lock
[formats]
simple = "%m%n"
[rules ]
[rules]
my_cat.* $mystd;simple
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