elephant_vending_machine.libraries.experiment_logger module

Experiment logging utilities.

This module contains functionality required to create a custom logger which writes messages and the corresponding UTC timestamp to csv files.

class elephant_vending_machine.libraries.experiment_logger.CsvFormatter[source]

Bases: logging.Formatter

Instances of CsvFormatter are used to convert a LogRecord instance to text.

CsvFormatter instances convert LogRecord instances to a properly formatted line in a csv file.

format(record)[source]

Format the specified record as text formatted for csv file.

The specified record is formatted as csv compatible text containing the current UTC timestamp and the record message.

Parameters

record (LogRecord) – The log record to be formatted

Returns

a string formatted as an entry for a csv file containing current UTC timestamp and record text

Return type

str

elephant_vending_machine.libraries.experiment_logger.create_experiment_logger(file_name)[source]

Create experiment logger to log record to csv file.

The specified record is formatted as csv compatible text containing the current UTC timestamp and the record message.

Parameters

file_name (str) – The name of the file to which the logs will be written

Returns

experiment_logger instance configured to write INFO level logs to log directory

Return type

Logger