You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-7Lines changed: 18 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,8 @@
2
2
3
3
zlog is a reliable, high-performance, thread safe, flexible, clear-model, pure C logging library.
4
4
5
-
Actually, in the C world there was NO good logging library for applications like logback in java or log4cxx in c++. Using printf can work, but can not be redirected or reformatted easily. syslog is slow and is designed for system use.
5
+
Actually, in the C world there was NO good logging library for applications like logback in java or log4cxx in c++.
6
+
Using printf can work, but can not be redirected or reformatted easily. syslog is slow and is designed for system use.
6
7
So I wrote zlog.
7
8
It is faster, safer and more powerful than log4c. So it can be widely used.
8
9
@@ -24,25 +25,32 @@ make PREFIX=/usr/local/
24
25
sudo make PREFIX=/usr/local/ install
25
26
```
26
27
27
-
PREFIX indicates the installation destination for zlog. After installation, refresh your dynamic linker to make sure your program can find zlog library.
28
+
PREFIX indicates the installation destination for zlog. After installation, refresh your dynamic linker to make sure
29
+
your program can find zlog library.
28
30
29
31
```bash
30
32
$ sudo vi /etc/ld.so.conf
31
33
/usr/local/lib
32
34
$ sudo ldconfig
33
35
```
34
36
35
-
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 are for linux. Other systems will need a similar set of actions.
37
+
Before running a real program, make sure libzlog.so is in the directory where the system's dynamic lib loader can find
38
+
it. The command metioned above are for linux. Other systems will need a similar set of actions.
36
39
37
40
## 2. Configuration file
38
41
39
42
There are 3 important concepts in zlog: categories, formats and rules.
40
43
41
-
Categories specify different kinds of log entries. In the zlog source code, category is a `zlog_cateogory_t *` variable. In your program, different categories for the log entries will distinguish them from each other.
44
+
Categories specify different kinds of log entries. In the zlog source code, category is a `zlog_cateogory_t *` variable.
45
+
In your program, different categories for the log entries will distinguish them from each other.
42
46
43
47
Formats describe log patterns, such as: with or without time stamp, source file, source line.
44
48
45
-
Rules consist of category, level, output file (or other channel) and format. In brief, if the category string in a rule in the configuration file equals the name of a category variable in the source, then they match. Still there is complex match range of category. Rule decouples variable conditions. For example, log4j must specify a level for each logger(or inherit from father logger). That's not convenient when each grade of logger has its own level for output(child logger output at the level of debug, when father logger output at the level of error)
49
+
Rules consist of category, level, output file (or other channel) and format. In brief, if the category string in a rule
50
+
in the configuration file equals the name of a category variable in the source, then they match. Still there is complex
51
+
match range of category. Rule decouples variable conditions. For example, log4j must specify a level for each logger(or
52
+
inherit from father logger). That's not convenient when each grade of logger has its own level for output(child logger
53
+
output at the level of debug, when father logger output at the level of error)
46
54
47
55
Now create a configuration file. The function zlog_init takes the files path as its only argument.
48
56
@@ -55,7 +63,9 @@ simple = "%m%n"
55
63
my_cat.DEBUG >stdout; simple
56
64
```
57
65
58
-
In the configuration file log messages in the category `my_cat` and a level of DEBUG or higher are output to standard output, with the format of simple `%m - usermessage %n - newline`. If you want to direct out to a file and limit the files maximum size, use this configuration
66
+
In the configuration file log messages in the category `my_cat` and a level of DEBUG or higher are output to standard
67
+
output, with the format of simple `%m - usermessage %n - newline`. If you want to direct out to a file and limit the
0 commit comments