Package Logger

This module defines class that can be used a package wide logger.

class PackageLogger(name, **kwargs)[source]

A class for package wide logging functionality.

Start logger for the package. Returns a logger instance.

Parameters:
  • prefix – prefix to console log messages, default is '@> '
  • console – log level for console (sys.stderr) messages, default is 'debug'
  • info – prefix to log messages at info level
  • warning – prefix to log messages at warning level, default is 'WARNING '
  • error – prefix to log messages at error level, default is 'ERROR '
addHandler(hdlr)[source]

Add the specified handler to this logger.

clear()[source]

Clear current line in sys.stderr.

close(filename)[source]

Close logfile filename.

critical(msg)[source]

Log msg with severity ‘CRITICAL’.

debug(msg)[source]

Log msg with severity ‘DEBUG’.

delHandler(index)[source]

Remove handler at given index from the logger instance.

error(msg)[source]

Log msg with severity ‘ERROR’ and terminate with status 2.

exit(status=0)[source]

Exit the interpreter.

getHandlers()[source]

Returns handlers.

info(msg)[source]

Log msg with severity ‘INFO’.

progress(msg, steps, label=None, **kwargs)[source]

Instantiate a labeled process with message and number of steps.

report(msg='Completed in %.2fs.', label=None)[source]

Write msg with timing information for a labeled or default process at debug logging level.

sleep(seconds, msg='')[source]

Sleep for seconds while updating screen message every second. Message will start with 'Waiting for Xs ' followed by msg.

start(filename, **kwargs)[source]

Start a logfile. If filename does not have an extension. .log will be appended to it.

Parameters:
  • filename – name of the logfile
  • mode – mode in which logfile will be opened, default is “w”
  • backupcount – number of existing filename.log files to backup, default is 1
timeit(label=None)[source]

Start timing a process. Use timing() and report() to learn and report timing, respectively.

timing(label=None)[source]

Returns timing for a labeled or default (None) process.

update(step, msg=None, label=None)[source]

Update progress status to current line in the console.

warn(msg)

Log msg with severity ‘WARNING’.

warning(msg)[source]

Log msg with severity ‘WARNING’.

write(line)[source]

Write line into sys.stderr.

prefix

String prepended to console log messages.

verbosity

Verbosity level of the logger, default level is debug. Log messages are written to sys.stderr. Following logging levers are recognized:

Level Description
debug Everything will be printed to the sys.stderr.
info Only brief information will be printed.
warning Only warning messages will be printed.
none Nothing will be printed.