Improved juju logging API

Ian Booth ian.booth at canonical.com
Mon Mar 18 04:30:55 UTC 2013


Fellow (Go) juju hackers

A small change is being landed to the logging API used by Go juju. Instead of
log.Printf()/Debugf(), we now have APIs which reflect the severity of the log
message:

log.Noticef(format string, a ...interface{})
log.Errorf(format string, a ...interface{})
log.Warningf(format string, a ...interface{})
log.Infof(format string, a ...interface{})
log.Debugf(format string, a ...interface{})

The juju commands also set the standard log Prefix string to reflect the name of
the command.

This change is a small step towards standardising the log output to facilitate
easy filtering and parsing of log messages, important for support tools and
scripts etc.

The current implementation providing a boolean flag used to control whether
debug level messages are logged is unchanged. Ultimately we will consider
runtime filtering of log messages based on source, severity, lifecycle (eg log
debug and above when bootstrapping, revert to info and above after charm
deployment etc). However, any subsequent work is not for pre 13.04.

At a high level, the current usage patterns for the above APIs goes something like:
Notice - agent / service start, stop, restart
Error - issues which mean the system is broken and cannot recover or impaired
functionality
Warning - issues which need attention but the system can still function
Info - general messages
Debug - low level detail necessary to diagnose problems

This work is currently up for review, but I wanted to give a heads up prior to
landing.



More information about the Juju-dev mailing list