europi_log
Assorted functions to make text-based logging easier
We define 4 levels of log: - info – general status information, high-level execution flow - warning – warnings that something’s unusual, but not necessarily broken - error – a critical error that means our module has stopped working - debug – developer-oriented debugging information
Each log item has a level and a tag associated with it. The tag should be unique to each module to make tracing the source of warnings easier
Log messages are written to the console and saved to /europi_log.txt. Importing
the europi
module will reset the log file.
- europi_log.init_log()
Initialize the log file.
This is done automatically by europi.py when it is imported
- europi_log.log_debug(message, tag=None)
Log a debugging message.
Debug messages are for developers and can contain very low-level, code-related information.
- Parameters
message – The message to log
tag – An optional tag to use as a prefix (e.g. the module name)
- europi_log.log_error(message, tag=None)
Log an error message.
Errors are critical and may indicate a crash, missing hardware, or other unrecoverable errors.
- Parameters
message – The message to log
tag – An optional tag to use as a prefix (e.g. the module name)
- europi_log.log_info(message, tag=None)
Log a simple information message.
- Parameters
message – The message to log
tag – An optional tag to use as a prefix (e.g. the module name)
- europi_log.log_warning(message, tag=None)
Log a warning message.
Warnings indicate an abnormal state, but are recoverable or can be worked-around.
- Parameters
message – The message to log
tag – An optional tag to use as a prefix (e.g. the module name)
- europi_log.write_log_entry(log_entry: str)
Write line to the log.
When logged, the message is written to the console and saved to /europi_log.txt
- Parameters
log_entry – The line of text to write to the log