What's new in Python 2.6: logging

The What's New in Python 2.6 document is very good and contains loads of information, congrats for making it. But it misses out a nice addition to the logging module: LoggerAdapter Objects. It allows you to create a logger object with extra contextual information really easy:

log = logging.LoggerAdapter(logging.getLogger("subsystem"),
                            {"argv1": sys.argv[1]})
logging.basicConfig(format="%(argv1)s %(message)s")

Neat

Secondly it decided to define __all__ which means not all object are exported anymore. Unfortunately this __all__ is incomplete in 2.6.2, even getLogger is not listed in it! The good news is that this is one of the fastest bug report turnaround times I have seen, so expect this to be fixed in the next stable release.