Ingenia Logger

ingenialogger.get_logger(name, axis=None, drive=None, category=None, code_error=None)

Return logger with target name.

Parameters
  • name (str) – logger name.

  • axis (int) – default value for logger axis. None as a default.

  • drive (str) – default value for logger drive. None as a default.

  • category (str) – default value for error type. None as default.

  • code_error (str) – default value for error identifier. None as a default.

Returns

return logger

Return type

IngeniaAdapter

ingenialogger.configure_logger(level=30)

Do Ingenia configuration for the logging system. By default configure a StreamHandler.

Parameters

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

ingenialogger.configure_file_handler(filename)

Configure a FileHandler.

Parameters

filename (str) – Path to the file where the log will be stored.

ingenialogger.configure_queue_handler()

Configure a QueueHandler.

Returns

Log queue.

Return type

queue.Queue

ingenialogger.clean_ingenia_handlers()

Clean ingenia handlers.

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
PUBLIC_DEBUG = 15
INFO = 20
PUBLIC_INFO = 25
WARNING = 30
PUBLIC_WARNING = 35
ERROR = 40
PUBLIC_FAULT = 43
PUBLIC_ERROR = 45
CRITICAL = 50