Logging Tools

Module Functions

l2l.logging_tools.create_shared_logger_data(logger_names, log_levels, log_to_consoles, sim_name, log_directory)[source]

This function must be called to create a shared copy of information that will be required to setup logging across processes. This must be run exactly once in the root process.

  • logger_names – This is a list of names of the loggers whose output you’re interested in.
  • log_levels – This is the list of the same size of logger_names containing the log levels specified as strings (e.g. ‘INFO’, ‘DEBUG’, ‘WARNING’, ‘ERROR’).
  • log_to_consoles – This is a list of the same size of logger_names containing boolean values which indicate whether or not to redirect the output of the said logger to stdout or not. Note that with scoop, and output to stdout on any worker gets directed to the console of the main process.
  • sim_name – This is a string that is used when creating the log files. Short for simulation name.
  • log_directory – This is the path of the directory in which the log files will be stored. This directory must be an existing directory.

This function configures the loggers using the shared information that was set by create_shared_logger_data(). This function must be run at the beginning of every function that is parallelized in order to be able to reliably configure the loggers. As an example look at its usage in the method simulate() from the class FunctionGeneratorOptimizee

You may also wish to call this function in your main simulation (after calling create_shared_logger_data()) to configure the logging for the root process before any of the parallelized functions are run.

Parameters:exactly_once – If the configuration of logging is causing a significant overhead per parallelized run (This is a rather unlikely scenario), then this value may be set to True. When True, the function will configure the loggers exactly once per scoop worker.