Log Messages Style
Rules for log messages
- message is not terminated by new line
- message is not terminated by dot
- messages starts with a lower-case letter, unless the first word is an upper-case word (AXFR, DNSSEC, etc.)
- parts of the message are separated by comma (not colon, semicolon, or dash)
- error string retrieved by
knot_strerror
or similar are appended at the end of the message and enclosed in parentheses - full name of unit is used instead of an abbreviation (e.g.
seconds
nots
orsec
) - brief message is better than a whole sentence
- delimit strings from outside properly (e.g. use
journal '%s', ...
orjournal, file '%s', ...
, notjournal %s ...
for filename inclusion)
Examples of valid messages
2014-08-13T16:55:43 info: Knot DNS 1.5.0 starting
2014-08-13T16:55:43 info: binding to interface 127.0.0.1@53533
2014-08-13T16:55:43 info: configured 1 interfaces and 2 zones
2014-08-13T16:55:43 info: loading zones
2014-08-13T16:55:43 info: starting server
2014-08-13T16:26:54 info: [example.com] zone will be loaded, serial 0
2014-08-13T16:26:54 info: [example.com] semantic checks completed
2014-08-13T16:26:54 info: [example.com] loaded, serial 0 -> 2
2014-08-13T16:54:04 info: [example.net] NOTIFY, outgoing, 127.0.0.1@53533: serial 1
2014-08-13T16:54:04 error: [test.com] AXFR, incoming, 127.0.0.1@53533: failed (connection refused)
2014-08-13T16:54:04 info: [example.net] AXFR, outgoing, 127.0.0.1@52996: started, serial 1
2014-08-13T16:54:04 info: [example.net] AXFR, outgoing, 127.0.0.1@52996: finished, 0.00 seconds, 1 messages, 421 bytes
2014-08-13T16:54:20 error: [test.com] AXFR, incoming, 127.0.0.1@53533: server responded with SERVFAIL
General rules
- zone name is not included in log message, designated
log_zone_*
function is used instead - use proper category
- messages should be emitted on high level, logging from internal functions should not be done and a proper error code should be used instead
Logging interface
Prefer using macros to low-level functions and log_zone_*
to log_zone_str_*
.
- server events macros:
log_fatal
,log_error
,log_warning
,log_notice
,log_info
,log_debug
- zone events macros (domain name):
log_zone_fatal
,log_zone_error
,log_zone_warning
,log_zone_notice
,log_zone_info
,log_zone_debug
- zone events macros (ASCII name):
log_zone_str_fatal
,log_zone_str_error
,log_zone_str_warning
,log_zone_str_notice
,log_zone_str_info
,log_zone_str_debug
- low-level functions:
log_msg
,log_msg_zone
,log_msg_zone_str