log message conventions

roger peppe roger.peppe at canonical.com
Wed Oct 10 16:21:47 UTC 2012


Currently there's no consistent convention for how we print
log messages.

A selection:

./worker/uniter/uniter.go:249: 	log.Printf("ran %q hook", hookName)
./environs/ec2/ec2.go:107: 	log.Printf("environs/ec2: opening
environment %q", cfg.Name())
./cmd/jujud/machine.go:77: 			log.Printf("machiner: rerunning machiner")
./state/watcher/watcher.go:359: 				log.Printf("watcher: changelog has
invalid collection document: %#v", c)

I'd summarise these as:
- prefix with package name (relative to launchpad.net/juju-core/)
- prefix with entity name (kinda)
- no prefix
- prefix with last element of package name.

I feel that it's useful to have some kind of identification on log messages,
so it's easy to sort out messages that are coming from particular system
components. (This particularly applies when we're running the provisioner,
firewaller and machine agent all in one executable).

If no-one else has a strong preference, might I suggest that we standardise
on the first possibility?  That is: prefix all log messages with the
name of the package that's printing the error message.
We could make the log package do this automatically if we like.

Thoughts?



More information about the Juju-dev mailing list