Logging

Logger classes used to generate structured logs in Flocker

Logger

class ave.utils.logger_api.Logger(workspace, guid, file_path='test_job_log.txt', lowest_level='x')

Handles all logging, pushes logs to Flocker and shouts Flocker links to Panotti, using the scheduler GUID as label.

Parameters:
  • workspace – Workspace that is used to push strings to Flocker.
  • guid – The global unique identifier that is used to set a label on the Flocker URL when it is uploaded to Panotti.
  • file_path – Name of the log file. Defaults to ‘test_job_log.txt’.
  • lowest_level – Sets the lowest level of log messages that should be added to log. Defaults to ‘x’ - unknown.
set_lowest_log_level(lvl)

Sets the lowest log level that should be added to log.

Parameters:lvl – Sets the lowest level of log messages that should be added to the log.
log_traceback(lvl)

Retrieves a stack trace and prints it to log.

Parameters:lvl – Sets the level of the log entry.
log_it(lvl, message, handset=None)

Logs the message with a time stamp, a level descriptor and a color code.

Parameters:
  • lvl – Sets the level of the log entry.
  • message – The message to log.
  • handset – Print the handset’s serial (Optional)
Returns:

The return parameter from Workspace.flocker_push_string().

parse_flocker_data(flocker_return)

Parses the flocker return value to a URL.

Parameters:flocker_return – The return value from Workspace.flocker_push_string().
Returns:A tuple: The Flocker URL and the Flocker session key.

LogLevel

Used by Logger to colorize strings and retrieving name and numeric value from a log level.

The different log levels:

'Level'         'Name'          'Numeric value'     'Color'
'd'             'DEBUG'         '10'                'White'
'i'             'INFO'          '20'                'Blue'
'w'             'WARNING'       '30'                'Yellow'
'e'             'ERROR'         '40'                'Red'
'x'             'UNKNOWN'       '0'                 'Purple'
ave.utils.logger.LogLevel.colorize_string(level, string)
Parameters:
  • level – The level to set color.
  • string – The string to colorize.
Returns:

The colorized string.

ave.utils.logger.LogLevel.get_level_numeric(level)
Parameters:level – The level to get the numeric value for.
Returns:The numeric value of the log level.
ave.utils.logger.LogLevel.get_level_name(level)
Parameters:level – The level to get the name for.
Returns:The name of the log level.
ave.utils.logger.LogLevel.verify_level(level)
Parameters:level – The level to verify
Returns:The level if it is an ok level
Raises :Exception if the level supplied is not an ok level

Table Of Contents

Previous topic

Utils

Next topic

Test Job Base Classes

This Page