In Chord source code, there are a great number of "warn", "warnx", "warnt", "fatal" and "panic". They are the output stream part of sfslite library and are used to replace the error output mechanics in standard C++ library in a asynchronous way. According to the tutorial of libasync from David and Frank, et al., these stream makes efforts to accumulate and write data to the terminal in chunks with reasonable boundaries.
This mechanic is defined in err.h and err.C in sfslite/async/ directory. There are some derivations for "warn":
warn:
- vwarn: invoke the underlying vfmt of strbuf.
- warnx: the program name and pid are shown in each message.
- warnt: a time stamp is shown in each message.
- vwarnx: invoke the underlying vfmt of strbuf with program name
and pid shown
fatal: message start with "fatal", exit program after messaging
panic: message start with "PANIC", exit and dump core after messaging.
assert: this is an replacement of C assert using the panic.
Here is what I found from the sfslite source code.
Actually, there is a quite similar mechanic in Chord called modlogger in chord/utils/modlogger.*, which is labelled an employed idea from sfslite. The modlogger is actually a small logging system with logging levels (CRIT, WARNING, INFO, TRACE) and logging target (standard output or a file descriptor).
No comments:
Post a Comment