Skip to content

Repository files navigation

gbe0 Log

My standard logging module.

Installation

To install from PyPI:

python3 -m pip install gbe0-log

Usage

To use in scripts check example.py.

Example:

## Import modulefromgbe0_logimportLoggerimportloggingaslog## Initialize logger## This only needs to be done onceLogger(verbosity=5)
## Log some messageslog.critical('A message to log at critical level') # Always logged (verbosity level 0)log.error('A message to log at error level') # Always logged (verbosity level 0)log.warning('A message to log at warning level') # Verbosity level 1log.info('A message to log at info level') # Verbosity level 2log.verbose('A message to log at verbose level') # Verbosity level 3log.debug('A message to log at debug level') # Verbosity level 4log.trace('A message to log at trace level') # Verbosity level 5

For convenience, a fatal log level has been added. If this log level is called it will log the message and cause the script to exit (with an optional error code). As an example:

## Log a fatal error and exit with default exit code (EINTR)log.fatal('A fatal error occured')
## Log a fatal error and exit with code 99log.fatal('A fatal error occured', code=99)

Example Output

Output is to stderr and looks like this:

Log output

Optimization

If Python is running in optimized mode calls to the following log levels are a no-op:

  • trace
  • debug
  • verbose

About

My logging

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages