ssapy_toolkit.IO.yu_logging
Functions
|
Set up a logging system that logs messages to a specified directory with a unique file for each ID. |
|
- 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:
- 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.