Comments (9)
I am thinking the same problem, but can't find a proper api to express it.
from zlog.
Hello,
Thank you HardySimpson for zlog. I agree wih avlarolm, zlog needs a way to be
initialized without an external file. In the project I'm currently working on
the design is zero-configuration; there are no external configuration files
at run time. For applications which do have configuration files, the
logging configuration would go into a section of a existing file which is
already processed by the application and calls APIs to configure various
software components.
As an initial workaround to try to evaluate zlog, I thought about having the
application create a temporary file before calling zlog_init(), but this was
ugly and error prone.
So, in order to start using zlog, I created a patch to read the configuration
from a text string embedded in the application which is passed to zlog at
startup. This of course is just a work around for now, but passing the string
is useful and easy to do. I added a new initialization function called
zlog_init_from_string() for now.
It seems much of the zlog initialization code is rather tightly wrapped around
the configuration file processing, so making the initialization more flexible
would take some thought about how to separate the data from the data source.
Perhaps an API that allows the application to build an configuration object then
pass it to a zlog initialization API would be useful.
Thank you,
Mike
from zlog.
Btw, I've been looking at how zlog parses the configuration text and was surprised at the amount of ad-hoc c code to scan and parse the configuration. Is there a reason a standard scanning and parsing design using lex and yacc (flex/bison) is not used? That would be much more maintainable, flexible, and likely generate faster less error prone code. I would provide an example if that would be helpful.
from zlog.
Totally agree meffie comments.
from zlog.
Actually, I think a lot of charm of zlog comes from it's syslog-like configure file. Many people tell me that configure file is hard to maintain. I agree with that. Still I need to say something to support configure file.
In most C program, it is hard to change behavior after you compile it. After modification of source code, you need to re-compile it, copy the executable to the product environment, and restart it. But the ability of change log output and level is always need at runtime. I mean, there is always a need to change how program out-put it's log when it is running in a high speed. That's why most log library need a configure file.
In many dynamic interpret language, it is easy to change it's behavior at runtime.
In python, the .py file is it's configure file.
Json provides a standard way of how javascript interpret it's data.
Lisp, I never use it, but heard that it is can be modified easily at runtime...
The base problem is between data and code. Most compile-language solve the problem by configure file(lightweight), or database(heavyweight).
In zlog's case, I think provide a two layer api maybe help.
It seems much of the zlog initialization code is rather tightly wrapped around
the configuration file processing, so making the initialization more flexible
would take some thought about how to separate the data from the data source.
Perhaps an API that allows the application to build an configuration object then
pass it to a zlog initialization API would be useful.
That's right, a 2-layer API will be better, I will try to learn lex and yacc.
from zlog.
Hello guys, I'm back.
I tried design no config api, but has no progess. Show my designs here. Hope get some advise
zlog_sinit("
[global]
default format = \"%m%n\"
[rules]
*.* > aa.log
");
this is ugly, put the configure file directly into c source.
the second way is
zlog_set("global", "default format = \"%m%n\"");
zlog_set("rules", "*.* > aa.log");
still ugly, but better than the first.
btw, I am redesigning configure syntax now, the sentence of rule is too long
*.* -"%12.2E(HOME)/log/%c.log", 1MB * 12 ~ "%E(HOME)/log/%c.%D(%F) #2r #3s.log"; simple
but there is no better way, I get something like this, but it it reductant
[*.*]
file path = -"%12.2E(HOME)/log/%c.log"
file path = +"%12.2E(HOME)/log/%c.log"
file permission = 0777
archive size = 1MB
archive number = 12
archive path = "%E(HOME)/log/%c.%D(%F) #2r #3s.log"
format = "%d %m%n"
from zlog.
I would suggest to have separate config structure that holds loggers formatters and appenders. That could be constructed using function calls, e.g.:
zlog_config *cfg = zlog_config_new();
zlog_config_add_logger(cfg, zlog_logger_new(/* ... */));
from zlog.
Hi Guys, is there any update for this issue ?
from zlog.
Any further update on this?
from zlog.
Related Issues (20)
- 每次调用dzlog_info都需要调用一次zlog_fini()吗
- 单日志文件大小达到5988876288b时,无法写入
- 如下代码中,日志写到一定大小就无法继续写了,使用文件转档功能也不行
- auto tool 的repo中,MacOSX 上无法通过编译,因为`pthread_threadid_np`不可见 HOT 2
- zlog日志转储相关配置的疑问
- hzlog接口打印内容不带数组名和长度
- 0x000000000040c1eb in zlog_event_del (a_event=0x2d3630445233322d) HOT 2
- Wrong version in version.h
- 日志切割配置以GB为单位不生效(zlog版本:1.2.12) HOT 1
- Is this library multiprocess safe? HOT 7
- 多进程写同一日志文件安全吗
- 配置规则没有生效 HOT 1
- 是否会加入异步写入文件的功能?
- zlog-1.2.16版本中转档失败问题
- 在1.2.12版本 获取锁仍然还是存在bug HOT 3
- 使用ZLOG进行日志打印的时候出现crash
- 使用最新版本1.2.13的日志文件转档功能,会出现文件锁死锁的现象。
- zlog加上轮转,在fork多进程情况下运行几千次还是会死锁 HOT 2
- zlog is blocked at the `write()` system call, causing the program to hang. HOT 2
- Severe Vulnerability in zlog 1.2.17 HOT 20
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zlog.