Alternative formatting styles for logging events in Python 3.3

Via the new "style" parameter to logging.Formatter objects, Python 3.2 adds support for newer formatting styles (str.format, string.template) when defining output formats for log messages. However, actual logging calls are still constrained to using %-formatting if they want to benefit from the "lazy formatting" feature (you can obviously generate pre-formatted messages any way you like). For 3.3, I'd like to propose extending this flexibility to the input side as well: 1. Add an optional style parameter to logging.Logger and logging.getLogger. This would then become the "default style" for any messages logged using that logger. In the case of getLogger, if the logger already exists and the styles don't match, raise an exception. 2. Add an optional style parameter to the Logger event recording methods (debug(), info(), et al) and the module level convenience functions. If supplied, this would override the default choice configured in the logger for that particular message. By default, all loggers (including the root logger) would continue to expect %-formatting. However, applications and libraries would be free to use the alternative formatting for their own logging without affecting other loggers. Thoughts? Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (1)
-
Nick Coghlan