log message conventions

Gustavo Niemeyer gustavo.niemeyer at canonical.com
Wed Oct 10 16:44:27 UTC 2012


+1

As a point worth noting, log message != error message. The convention
covered in this thread is for log.Printf and log.Debugf, specifically.


On Wed, Oct 10, 2012 at 1:21 PM, roger peppe <roger.peppe at canonical.com> wrote:
> 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?
>
> --
> Juju-dev mailing list
> Juju-dev at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju-dev



-- 
gustavo @ http://niemeyer.net



More information about the Juju-dev mailing list