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 '
-
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()
andreport()
to learn and report timing, respectively.
-
warn
(msg)¶ Log msg with severity ‘WARNING’.
-
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.
- prefix – prefix to console log messages, default is