Setting up logging — bornprofiler.log

Configure logging for the BornProfiler. Import this module if logging is desired in application code.

Logging to a file and the console.

See http://docs.python.org/library/logging.html?#logging-to-multiple-destinations

The top level logger of the library is named ‘bornprofiler’. Note that we are configuring this logger with console output. If the root logger also does this then we will get two output lines to the console. We’ll live with this because this is a simple convenience library and most people will not bother with a logger (I think…)

In modules that use loggers get a logger like so::
import logging logger = logging.getLogger(‘bornprofiler.MODULENAME’)
class bornprofiler.log.NullHandler(level=0)[source]

Silent Handler.

Useful as a default::
h = NullHandler() logging.getLogger(“bornprofiler”).addHandler(h) del h

Initializes the instance - basically setting the formatter to None and the filter list to empty.

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

bornprofiler.log.clear_handlers(logger)[source]

clean out handlers in the library top level logger

(only important for reload/debug cycles…)

bornprofiler.log.create(logger_name='bornprofiler', logfile='bornprofiler.log')[source]

Create a top level logger.

  • The file logger logs everything (including DEBUG).
  • The console logger only logs INFO and above.

Logging to a file and the console.

See http://docs.python.org/library/logging.html?#logging-to-multiple-destinations

The top level logger of the library is named ‘bornprofiler’. Note that we are configuring this logger with console output. If the root logger also does this then we will get two output lines to the console. We’ll live with this because this is a simple convenience library…