update_logger_file_suffix
- gratools.update_logger_file_suffix(logger, new_file_suffix)[source]
Updates file handlers of a logger to use a new file suffix. Existing log content from the old file (if any) is copied to the new file location before switching. The old file is then deleted.
This is useful if, for instance, a specific operation (like a query) should have its logs in a uniquely named file determined mid-execution.
Parameters
- loggerlogging.Logger
The logger instance whose file handlers need updating.
- new_file_suffixstr
The new suffix to be incorporated into the log filenames. Example: if old was “main_log.log”, new_suffix=”_query123”, new becomes “main_log_query123.log”.
Returns
- logging.Logger
The same logger instance, now with updated file handlers.