rootpy/rootpy — pull request #62 by pwaller (2012-11-16 15:22:07+00:00)
Title: WIP: Epic logging commit

This pull request contains a nice logging interface for rootpy to use internally and applications to use if they want, whilst affording applications the opportunity to do exactly what they want.

If there is no log handler at the point when rootpy (or ROOT) tries to emit a log message, rootpy creates a global one with colourized (if we're connected to a terminal) output and maximum verbosity, and emits a warning.

Very little existing code is touched, other than to add the new `log` variable to the subpackages. From now on if you introduce a new subpackage, you should write:

from .. import log; log = log[__name__]

Then `log.debug()` will appear to come from the namespace of the subpackage.

This module introduces a number of experimental changes.

The major new feature is that ROOT's logging system now directs its messages through python's `logging` module. This means that they can be filtered using standard [logging](http://docs.python.org/2/library/logging.html) features.

For maximum testing effectiveness, please do this:

:dragon: :dragon_face: :dragon:

import rootpy.logger.magic as M; M.DANGER.enabled = True

:dragon: :dragon_face: :dragon:

This enables rewriting the bytecode of a function in a calling frame at runtime. Slightly insane, but it's worth it because it can turn ROOT error messages into exceptions. An attempt at making sure multiple threads don't clobber each other is made by setting `sys.setcheckinterval` very high. This hopefully makes the possibility of a race condition where one thread is running an exception and another is following the non-exceptional route where there exists modified bytecode very unlikely, but not guaranteed.

Included in this commit are tests (which enable `M.DANGER`) and documentation.

### Please run nosetests and report back.
### In particular can someone test 32 bit for me?