lovebeat
lovebeat copied to clipboard
Loglevel defaults to debug when using syslog backend
When starting with -syslog
the loglevel defaults to debug instead of info. Starting a Lovebeat container with
docker run -v /dev/log:/dev/log boivie/lovebeat:1.0.3 -syslog
yields the following syslog entries:
Jul 29 23:20:38 bertie lovebeat[1]: Debug logs enabled
Jul 29 23:20:38 bertie lovebeat[1]: lovebeat v1.0.3 (built w/go1.8)
Jul 29 23:20:38 bertie lovebeat[1]: Started on 92295984ad94, PID 1, running from
/data
Jul 29 23:20:38 bertie lovebeat[1]: No metrics reporting configured
Jul 29 23:20:38 bertie lovebeat[1]: Couldn't open 'lovebeat.db'
Jul 29 23:20:38 bertie lovebeat[1]: Sending mail via SMTP at localhost:25, from
[email protected]
Jul 29 23:20:38 bertie lovebeat[1]: TCP listening on :8127
Jul 29 23:20:38 bertie lovebeat[1]: HTTP listening on :8080
Jul 29 23:20:38 bertie lovebeat[1]: UDP listening on :8127
Jul 29 23:20:39 bertie lovebeat[1]: UPDATE: {"ts":1532899239215,"tick":{}}
Jul 29 23:20:40 bertie lovebeat[1]: UPDATE: {"ts":1532899240215,"tick":{}}
Jul 29 23:20:41 bertie lovebeat[1]: UPDATE: {"ts":1532899241215,"tick":{}}
...
Apart from the obvious "Debug logs enabled" at the top the "UPDATE" messages are logged at debug level and shouldn't have appeared here. To be clear, I don't think this bug is Docker-specific; it just happens to be the environment where I discovered the issue.
I suspect this is because
if *debug {
logging.SetLevel(logging.DEBUG, "lovebeat")
} else {
logging.SetLevel(logging.INFO, "lovebeat")
}
in lovebeat.go runs prior to the syslog backend initialization which effectively clears the level config and defaults to debug unless a level has been explicitly set (see https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/level.go#L90-L100).
I can't test this hypothesis and send a patch right now but I hope I'll have time to have a look at it later (if nothing else because I have a self-interest in working syslog logging).