Logging Configuration

When MudPi is executed it will display output to the terminal based on the set log level. The Logger included with MudPi logs data to both the terminal (stdout) and a file. You can specify different log levels for both output streams.

Typically this output is already sent to a file or discarded if you are using an process monitor like supervisor. However it can be useful to log data to a file with a different verbosity than what is output in the terminal. The logger has a few basic configurations. The log file will be stored relative to the root where MudPi is installed unless you provide an absolute path.

Config

"logging": {
    "file_log_level": "debug",
    "terminal_log_level": "debug",
    "file": "mudpi.log"
},

Settings

OptionTypeRequiredDescription
file_log_level[String]NoLog level for file out logging. Options are debug, info, warn, critical, error. The log file is set using the file option.
terminal_log_level[String]NoLog level for the terminal output. Options are debug, info, warn, critical, error.
file[String]NoFull path including filename of the log file. If just a filename is provided then the file is stored in MudPi root location (typically /etc/mudpi/core).

Logger Usage

When logging all messages are written also to a log file (if set up in the configs) with a different format [%(asctime)s][%(name)s][%(levelname)s] %(message)s while they are printed unedited to stdout.

The logging module allows you to select different logging levels for each handler (stdout or log file).

Example

Here is an example of how the log output would be displayed between both stdout and a file.

stdout (Supports Text Color, not show below)

Initializing Logger...                   Complete

Log File (default mudpi.log)

[15:24:14][EVE][INFO] Initializing Logger...			 Complete

If debug is set to true in the configuration, all logging levels are automatically set to "debug" regardless of the configuration.