Skip to content

tqdm ​

TqdmSink redirects log output through tqdm progress bars, preventing log messages from interfering with active progress bars.

Installation ​

This integration requires the tqdm package.

bash
uv add logly[tqdm]
bash
pip install "logly[tqdm]"
bash
uv add tqdm
bash
pip install tqdm

Missing Dependency

If tqdm is not installed, you'll see:

ModuleNotFoundError: No module named 'tqdm'

Usage ​

python
from logly import logger
from logly.integrations.tqdm import TqdmSink
from tqdm import tqdm

logger.remove()
logger.add(TqdmSink(), colorize=True)

for i in tqdm(range(100)):
    if i % 20 == 0:
        logger.info("Processing item {}", i)

Full Example ​

python
from logly import logger
from logly.integrations.tqdm import TqdmSink
from tqdm import tqdm
import time

logger.remove()
logger.add(TqdmSink(), colorize=True)

for i in tqdm(range(100)):
    if i % 20 == 0:
        logger.info("Processing item {}", i)
    time.sleep(0.05)

logger.success("Processing complete")

Parameters ​

ParameterTypeDefaultDescription
tqdm_instanceAnyNoneOptional tqdm class or instance. Uses tqdm.tqdm if None.

Notes ​

  • Uses tqdm.write() to safely output log messages without breaking progress bar display
  • Integrates cleanly with tqdm progress bars without interfering with their display
  • Supports colorize=True for colorized log output

Released under the MIT License.