logger.py

This module defines amoco logging facilities. The Log class inherits from a standard logging.Logger, with minor additional features like a 'VERBOSE' level introduced between 'INFO' and 'DEBUG' levels, and a progress method that can be useful for time consuming activities. See below for details.

Most amoco modules start by creating their local logger object used to provide various feedback. Users can thus focus on messages from selected amoco modules by adjusting their level independently, or use the set_quiet(), set_debug() or set_log_all(level) functions to adjust all loggers at once.

Examples

Setting the mapper module to 'VERBOSE' level:

In [1]: import amoco
In [2]: amoco.cas.mapper.logger.setlevel('VERBOSE')

Setting all modules loggers to 'ERROR' level:

In [2]: amoco.logger.set_quiet()

Note: All loggers can be configured to log both to stderr with selected level and to a unique temporary file with 'DEBUG' level. See configuration.

class logger.Log(name, handler=<StreamHandler <stderr> (NOTSET)>)[source]

This class is intended to allow amoco activities to be logged simultaneously to the stderr output with an adjusted level and to a temporary file with full verbosity.

All instanciated Log objects are tracked by the Log class attribute Log.loggers which maps their names with associated instances.

The recommended way to create a Log object is to add, near the begining of amoco modules:

from amoco.logger import Log
logger = Log(__name__)
setLevel(lvl)[source]

Set the logging level of this logger. level must be an int or a str.

logger.set_quiet()[source]

set all loggers to 'ERROR' level

logger.set_debug()[source]

set all loggers to 'DEBUG' level

logger.set_log_all(level)[source]

set all loggers to specified level

Parameters:level (int) – level value as an integer.
logger.reset_log_file(filename, level=10)[source]

set DEBUG log file for all loggers.

Parameters:filename (str) – filename for the FileHandler added to all amoco loggers