Ingenia Logger

ingenialogger.get_logger(name)

Return logger with target name.

Parameters

name – logger name.

Returns

return logger

Return type

logging.LoggerAdapter

ingenialogger.configure_logger(level=30, queue=False, file=None)

Do Ingenia configuration for the logging system. By default configure a StreamHandler, but can configure a QueueHandler and FileHandler.

Parameters
  • level (int) – set the root logger level to the specified level. logging.WARNING by default.

  • queue (bool) – if True, configure a QueueHandler and return the queue, if False do nothing. False by default.

  • file (str) – if set, configure a FileHandler with this param as filename. None by default.

Returns

if queue is True return the queue, if it is False return None.

Return type

queue.Queue or None

class ingenialogger.LogParser
static parse_log(log)

From a target log line, return a dict with logs timestamp, logger name, level, message and custom fields.

Parameters

log (str) – log line string.

Returns

Dictionary with all the log fields. Example:

{
    'timestamp': '2021-03-24 13:16:29,335',
    'logger': 'root',
    'level': 'INFO',
    'message': 'Example log'
    'fields': {
        'axis': 1
    }
}

Return type

dict

static parse_message(msg)

From a target log message, return a dict with message and custom fields.

Parameters

msg (str) – log message.

Returns

Dictionary with log message and custom fields. Example:

{
    'message': 'Example log'
    'fields': {
        'axis': 1
    }
}

Return type

dict

static parse_fields(fields_str)

From a target log fields, return a dict with fields.

Parameters

fields_str (str) – string with log custom fields.

Returns

Dictionary with log custom fields. Example:

{
    axis': 1
}

Return type

dict

class ingenialogger.LoggingLevel(value)

An enumeration.

NOTSET = 0
DEBUG = 10
USER_DEBUG = 15
INFO = 20
USER_INFO = 25
WARNING = 30
USER_WARNING = 35
ERROR = 40
USER_ERROR = 45
CRITICAL = 50