Popular recipes by Bud P. Bruegger http://code.activestate.com/recipes/users/4175472/2010-11-02T10:04:15-07:00ActiveState Code Recipeseasy logging with extras (Python)
2010-11-02T10:04:15-07:00Bud P. Brueggerhttp://code.activestate.com/recipes/users/4175472/http://code.activestate.com/recipes/577448-easy-logging-with-extras/
<p style="color: grey">
Python
recipe 577448
by <a href="/recipes/users/4175472/">Bud P. Bruegger</a>
(<a href="/recipes/tags/logging/">logging</a>).
</p>
<p>The logging package offers the "extra" keyword argument in Logger.log to add user-defined attributes to the log record. LoggerAdaptors make it easy to use extras that are constant for a given logger; then simply use logger.debug, logger.info, ecc. But this won't support variable extra arguments. </p>
<p>The present recipe makes it easy to use "extra" attributes that are not constant but variables passed to the (modified) logging methods ('debug', 'info', ...)</p>
logging support for python daemon (Python)
2010-10-25T15:22:18-07:00Bud P. Brueggerhttp://code.activestate.com/recipes/users/4175472/http://code.activestate.com/recipes/577442-logging-support-for-python-daemon/
<p style="color: grey">
Python
recipe 577442
by <a href="/recipes/users/4175472/">Bud P. Bruegger</a>
(<a href="/recipes/tags/daemon/">daemon</a>, <a href="/recipes/tags/logging/">logging</a>).
</p>
<p>The recipe shows how to subclass python-daemon's [1] DaemonContext to add logging support. In particular, it is possible to ask to keep the files related to a list of loggers (loggers_preserve) open and to redirect stdout and stderr to a logger (e.g., one using a RotatingFileHandler). </p>
<p>[1] See <a href="http://pypi.python.org/pypi/python-daemon/" rel="nofollow">http://pypi.python.org/pypi/python-daemon/</a></p>