Skip to content

Draft: re-work logging, log to syslog, introduce log levels

Marc Haber requested to merge logging into master

Hi,

I have hacked up some preliminary prototype of a messagef function that should replace debugf/warnf/dief etc. In addition to doing the output to the console, it can also write messages to syslog, which is a new feature that I think could be handy to leave an audit trail during system and/or package installation.

All messages passed to messagef have a priority which is modeled after the priorities for syslog(3), and there are three configuration variables (settable as command line option, TODO: configuration file) to decide whether a message goes to stderr, stdout or into syslog.

I have also adapted the control flow for adduser --system (addsysuser) to use the new mechanism. It can be a slow migration, both mechanisms are currently present and useable. The old mechanism has not been touched (yet).

The code is badly tested, test cases have not been adapted (if necessary), no test cases have been written for messagef (how would I do that?), but adduser --system foo does not explode, smell or smoke.

Please comment. I especially hate the idea how I coded the values for the priorities. That surely can be done prettier. This has been subject of a rework on August 19, I snarfed some of the ideas from existing perl logging modules, so it cannot be that bad. Object oriented approaches would be to have message.fatal, message.error etc, but aren't we just moving away from the one-function-per-loglevel approach?

I am really interested in knowing what you think.

Greetings Marc

Edited by Marc Haber

Merge request reports

Loading