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)

Add the specified handler to this logger.

clear()

Clear current line in sys.stderr.

close(filename)

Close logfile filename.

critical(msg)

Log msg with severity ‘CRITICAL’.

debug(msg)

Log msg with severity ‘DEBUG’.

delHandler(index)

Remove handler at given index from the logger instance.

error(msg)

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

exit(status=0)

Exit the interpreter.

getHandlers()

Returns handlers.

info(msg)

Log msg with severity ‘INFO’.

progress(msg, steps, label=None, **kwargs)

Instantiate a labeled process with message and number of steps.

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

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

sleep(seconds, msg='')

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

start(filename, **kwargs)

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)

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

timing(label=None)

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

update(step, label=None)

Update progress status to current line in the console.

warn(msg)

Log msg with severity ‘WARNING’.

warning(msg)

Log msg with severity ‘WARNING’.

write(line)

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.