quirtylog.tqdm_logger
tqdm_logger.py
This module provides utilities for redirecting TQDM (progress bar library) output to a logger.
Classes
|
Output stream for TQDM which will output to logger module instead of the StdOut. |
- class quirtylog.tqdm_logger.TqdmToLogger(logger, level=20)
Bases:
StringIOOutput stream for TQDM which will output to logger module instead of the StdOut.
This class provides an output stream for TQDM (progress bar library) that directs the output to a specified logger instead of the standard output.
Initialize the TqdmToLogger instance.
- Parameters:
logger (
Logger) – A logger object to which TQDM output will be directed.level – The logging level to be used (default: logging.INFO).
This method initializes the TqdmToLogger instance with the specified logger and logging level. The logger is used to direct TQDM output, and the logging level determines the severity of log messages.
Example:
# Example usage of __init__ method in the TqdmToLogger class import logging from TqdmToLoggerModule import TqdmToLogger # Create a logger logger = logging.getLogger(__name__) # Initialize TqdmToLogger with the logger and custom logging level tqdm_out_logger = TqdmToLogger(logger=logger, level=logging.INFO)
- buf = ''
- logger = None
The logger object to which the TQDM output is directed.
- level = None
The logging level to be used when emitting log messages.
- write(buf)
Write the specified buffer content.
- Parameters:
buf (
str) – The buffer content to be written.
- flush()
Execute the flush operation, logging the buffered content.