Pensieri di un lunatico minore

1 August 2009 Python

Python logging

The current Python logging library is not well loved. Whether that’s because it feels derived from the Java logging tools, or just because it seems to require more incantations than feel Pythonic is irrelevent. It’s not loved; not even close.

Reading a posting by Edward Ream about improving the Python logging world, it strikes me as an interesting idea to wonder if logging should be less about hierarchies, and more about matrices. Strict hierarchical systems—think PKI, security classification, company org charts—tend to be brittle and require more than a little jerry-rigging to make function. With the rise of tagging in the Internet sphere, why not approach it from that perspective?

For example, instead of the debug levels:

  1. CRITICAL
  2. ERROR
  3. WARNING
  4. INFO
  5. DEBUG

plus the odd one of “UNSET’, we would use a simple tagging system. Rather than having a single filtering identifier, we could use n-filters. What this API looks like is a bit more uncertain. It loses it’s clear logging.debug() API, and requires a bit more information, but I think that a lot of this could be simplified through how you grab the logger object.

More thinking is necessary, but it would seem that this could also help address issues around auditing as well.

This entry was posted at 5:16 pm on 1 August 2009 and is filed under Python. You can follow any responses to this entry through the post-specific RSS 2.0 feed.

There is a logging library for Common Lisp called log5 (http://common-lisp.net/project/log5/overview.html). It is based on pretty much the same idea of having different categories of output and different destinations for different categories. You might want to look at its API for ideas.

Both comments and pings are currently closed.