medpy.core.logger.Logger#

class medpy.core.logger.Logger(name='MedPyLogger', level=0)[source]#

Logger to be used by all applications and classes.

Notes

Singleton class i.e. setting the log level changes the output globally.

Examples

Initializing the logger

>>> from medpy.core import Logger
>>> logger = Logger.getInstance()

Error messages are passed to stdout

>>> logger.error('error message')
15.09.2014 12:40:25 [ERROR   ] error message
>>> logger.error('critical message')
15.09.2014 12:40:42 [CRITICAL] critical message

But debug and info messages are suppressed

>>> logger.info('info message')
>>> logger.debug('debug message')

Unless the log level is set accordingly

>>> import logging
>>> logger.setLevel(logging.DEBUG)
>>> logger.info('info message')
15.09.2014 12:43:06 [INFO    ] info message (in <ipython-input-14-a08cad56519d>.<module>:1)
>>> logger.debug('debug message')
15.09.2014 12:42:50 [DEBUG   ] debug message (in <ipython-input-13-3bb0c512b560>.<module>:1)
__init__(name='MedPyLogger', level=0)[source]#

Initialize the logger with a name and an optional level.

Methods

__init__([name, level])

Initialize the logger with a name and an optional level.

addFilter(filter)

Add the specified filter to this handler.

addHandler(hdlr)

Add the specified handler to this logger.

callHandlers(record)

Pass a record to all relevant handlers.

critical(msg, *args, **kwargs)

Log 'msg % args' with severity 'CRITICAL'.

debug(msg, *args, **kwargs)

Log 'msg % args' with severity 'DEBUG'.

error(msg, *args, **kwargs)

Log 'msg % args' with severity 'ERROR'.

exception(msg, *args[, exc_info])

Convenience method for logging an ERROR with exception information.

fatal(msg, *args, **kwargs)

Don't use this method, use critical() instead.

filter(record)

Determine if a record is loggable by consulting all the filters.

findCaller([stack_info, stacklevel])

Find the stack frame of the caller so that we can note the source file name, line number and function name.

getChild(suffix)

Get a logger which is a descendant to this one.

getEffectiveLevel()

Get the effective level for this logger.

handle(record)

Call the handlers for the specified record.

hasHandlers()

See if this logger has any handlers configured.

info(msg, *args, **kwargs)

Log 'msg % args' with severity 'INFO'.

isEnabledFor(level)

Is this logger enabled for level 'level'?

log(level, msg, *args, **kwargs)

Log 'msg % args' with the integer severity 'level'.

makeRecord(name, level, fn, lno, msg, args, ...)

A factory method which can be overridden in subclasses to create specialized LogRecords.

removeFilter(filter)

Remove the specified filter from this handler.

removeHandler(hdlr)

Remove the specified handler from this logger.

setHandler(hdlr)

Replace the current handler with a new one.

setLevel(level)

Overrides the parent method to adapt the formatting string to the level.

warn(msg, *args, **kwargs)

warning(msg, *args, **kwargs)

Log 'msg % args' with severity 'WARNING'.

Attributes

getInstance

The member variable holding the actual instance of the class.

manager

root