ssapy_toolkit.IO.yu_logging

Functions

build_logging(id, log_dir)

Set up a logging system that logs messages to a specified directory with a unique file for each ID.

log_print(message[, show_prints])

ssapy_toolkit.IO.yu_logging.build_logging(id, log_dir)[source]

Set up a logging system that logs messages to a specified directory with a unique file for each ID.

Parameters:
  • id (int or str) – A unique identifier to associate with the log file and log messages.

  • log_dir (str) – The directory where the log file will be created. All necessary subdirectories will be created if they do not exist.

Return type:

None

Notes

  • The function ensures the log directory exists and removes any existing log file with the same name to start fresh.

  • Logs are saved in a file named id_<id>.log within the specified directory.

  • Each log message includes the ID, a timestamp, and the log message.

  • A custom log formatter is used to inject the ID into log messages.

  • The function prints a message to the console indicating where logging has been initialized.

Example

`python build_logging(id=123, log_dir="/path/to/logs") logging.info("This is a test log message.") ` This would create a log file at /path/to/logs/id_123.log and log the message with the given ID.

ssapy_toolkit.IO.yu_logging.log_print(message, show_prints=True)[source]