starling_sim.utils.simulation_logging
Simulation logs offer an insight of the flow of events during the simulation run. They are displayed in chronological order and contain various information such as simulation setup, output generation or agent activity.
Simulation logs are managed with the Python logging library.
Simulation logging levels
In addition to the base levels of logging, we introduce two new ones:
An agent level that displays the agents’ activities
An algorithm level that displays the algorithms’ steps
This results in the following available levels:
Level |
Numeric value |
---|---|
CRITICAL |
50 |
ERROR |
40 |
WARNING |
30 |
INFO |
20 |
AGENT |
15 |
ALGO |
13 |
DEBUG |
10 |
The default logging level is 13.
To run a simulation with a different logging level, you can use the -l
(or --level
) option of main.py.
For instance:
python3 main.py data/models/SB_VS/example_nantes/ -l 20
Simulation loggers
We also create specific loggers for the Traced
and
Algorithm
classes with
different logging formats, in order to display additional information (such as the simulation time). For instance:
AGENT :: [50904], S1 : Picked up u-11
In order to display logs, instances of these classes call their internal method log_message so the relevant information is fetched directly from their attributes and a default level is applied.
These additional loggers may also be used by any module developed around Starling to display simulation logs.
Module Contents
Functions
|
Setup the logging configuration for the run. |
Create and return a logger for the traced agents. |
|
Create and return a logger for the simulation algorithms. |
|
Create and return a logger without prefix. |
Attributes
- starling_sim.utils.simulation_logging.BASE_LOGGER_FORMAT = '%(levelname)s :: %(message)s'
- starling_sim.utils.simulation_logging.DEFAULT_LOGGER_LEVEL = 13
- starling_sim.utils.simulation_logging.setup_logging(logger_level)
Setup the logging configuration for the run.
- Parameters:
logger_level – integer describing the logger level
- starling_sim.utils.simulation_logging.TRACED_LOGGER_FORMAT = '%(levelname)s :: [%(timestamp)s], %(id)s : %(message)s'
- starling_sim.utils.simulation_logging.new_traced_logger()
Create and return a logger for the traced agents.
- Returns:
Logger object from the logging library
- starling_sim.utils.simulation_logging.ALGO_LOGGER_FORMAT = '%(levelname)s :: %(alg_name)s : %(message)s'
- starling_sim.utils.simulation_logging.new_algo_logger()
Create and return a logger for the simulation algorithms.
- Returns:
Logger object from the logging library
- starling_sim.utils.simulation_logging.BLANK_LOGGER_FORMAT = '%(message)s'
- starling_sim.utils.simulation_logging.new_blank_logger()
Create and return a logger without prefix.
- Returns:
Logger object from the logging library
- starling_sim.utils.simulation_logging.TRACED_LOGGER
- starling_sim.utils.simulation_logging.ALGO_LOGGER
- starling_sim.utils.simulation_logging.BLANK_LOGGER