Logger prefixes for api/apiserver are changing

Tim Penhey tim.penhey at canonical.com
Wed Sep 3 02:01:02 UTC 2014


On 02/09/14 23:07, David Cheney wrote:
> Wow. I'm sorry I broke that, it didn't even occur to me.
> 
> I wonder if there is a better way to handle this default case of "the
> name of the logger follows the package path"), ie
> 
> var logger = loggo.Logger("") // or something, it could be a new
> method, logger.Default(), or something.
> 
> which will inspect the call tree and determine its logger name automagically.

I'm fine with this in theory, but the implementation is a little different.

The behaviour that we have right now is something akin to stripping off
the DVCS path, then replacing slashes for dots to get to the package.

So files that were in
  github.com/juju/juju/state/apiserver/...
used
  "juju.state.apiserver"

There were two ideas proposed:

loggo.LoggerForPackage("juju")

which would walk up the path until it found a path element juju, and
construct the string that way. The other was do use a defined prefix:

loggo.LoggerForPackage("github.com/juju")

which would take what was after those path elements to generate the string.


I'm happy with either being implemented, but would like feedback on the
ideas.

Tim



More information about the Juju-dev mailing list