Logging (mpdaf.log)

When imported, MPDAF initialize a logger by default. This logger uses the logging module, and log messages to stderr, for instance for the .info() methods.

It is possible to remove this logger with clear_loggers, and to use setup_logging to setup a logger with a different level or format. setup_logfile can also be used to setup a logger with a file.



Remove all handlers for a given logger.

mpdaf.log.setup_logging(name='mpdaf', level='DEBUG', color=False, stream=None, fmt='[%(levelname)s] %(message)s', clear_handlers=True)[source]

Setup stream handler for a given logger.

name : str

Logger name.

level : str

Level for the stream handler (default: DEBUG).

color : bool

Use colored output (default: True). Used only if a compatible stream or tty is used.

stream : {sys.stdout, sys.stderr}

Used stream (default: stderr)

fmt : str

Messages format.

clear_handlers : bool

Tell if other handlers must be removed (default: True).

mpdaf.log.setup_logfile(name='mpdaf', level=10, logfile='mpdaf.log', fmt='%(asctime)s [%(levelname)s] {%(name)s:%(lineno)d} %(message)s', rotating=True)[source]

Setup logging to file.