demo_utils.logs module

A small submodule which makes logging easy for the whole library

Using this library you can initiate logging for any module in this package (or any python module in general)

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from demo_utils import logs
from logs import Logger

# Create the logger. Should be at the beginning of the file.
# Use throughout the module/file
l = Logger('your_logger_name').getLogger()

# Info
l.info('Info Message')
# Warn
l.warn('Warning Message')
# Error
l.error('Error Message')
# Debug
l.debug('Debug Message')

To set the logging level put a file called global.conf inside of your configuration directory. Use the following format to set the log level. If the file isn’t found we default to WARN.

Put the following inside global.conf to set the logging level

[LOGGING]
log-level=WARN
class demo_utils.logs.Logger(name)

Simple logger object to set up logging for a module

Parameters:name (str) – The name of the module/logger. Used in log output
getLogFile()

Attempts to retrieve the log-file parameter from global.conf

getLogger()

Get the logger object

Returns:The python logger object
Return type:object
getLoggingLevel()

Attempts to retrieve the logging level from the configuration file global.conf.

logger = <logging.Logger object>

The logger object. Uses the built-in python logger.