Logging Utilities
This module contains utilities for configuring logging.
- vivarium.engine.framework.logging.utilities.configure_logging_to_terminal(verbosity, long_format=True)[source]
Configure logging to print to the sys.stdout.
- Return type:
- Parameters:
verbosity (int) – The verbosity level of the logging. 0 logs at the WARNING level, 1 logs at the INFO level, and 2 or more logs at the DEBUG level.
long_format (bool) – Whether to use the long format for logging messages, which includes explicit information about the simulation context and component in the log messages.
- vivarium.engine.framework.logging.utilities.configure_logging_to_file(output_directory)[source]
Configure logging to write to a file in the provided output directory.
- vivarium.engine.framework.logging.utilities.add_logging_sink(sink, verbosity, long_format, colorize, serialize)[source]
Add a logging sink to the logger.
- Return type:
- Parameters:
sink (Path | TextIO) – The sink to add. Can be a file path, a file object, or a callable.
verbosity (int) – The verbosity level. 0 is the default and will only log warnings and errors. 1 will log info messages. 2 or more will log debug messages.
long_format (bool) – Whether to use the long format for logging messages. The long format includes the simulation name and component name. The short format only includes the file name and line number.
colorize (bool) – Whether to colorize the log messages.
serialize (bool) – Whether to serialize log messages. This is useful when logging to a file or a database.