Logging utilities that work well with tqdm
Project description
Installation
pip install logging-tee
Usage
import logging
from tqdm import tqdm
import time
from logging_tee import setup_logger
if __name__ == "__main__":
setup_logger(log_file="output.log", level=logging.DEBUG)
logger = logging.getLogger()
logger2 = logging.getLogger("test_logger2")
for i in tqdm(
range(2),
desc="Processing",
):
time.sleep(0.03)
logger.info("Processing item %d", i)
for outer_idx in tqdm(
range(2),
desc="Outer",
):
for inner_idx in tqdm(
range(3),
desc=f"Inner {outer_idx}",
):
time.sleep(0.02)
if inner_idx % 5 == 0:
print(f"Nested step outer={outer_idx} inner={inner_idx}")
logger.info(f"Completed outer={outer_idx}")
print("from print statement")
print("multiple lines\nfrom print statement 2")
logger.debug("Single line")
logger.debug("Multiple lines:\nnext line")
logger.debug("Another single line")
logger.debug("Multiple lines:\n%s", "next line\nnext line 2")
logger.warning("Warning message\nwith multiple lines\nand should be logged properly.")
logger.error("Error message\nwith multiple lines\nand should be logged properly.")
logger2.info("Logger2 info message\nwith multiple lines\nand should be logged properly.")
raise ValueError("This is an error message\nwith multiple lines\nand should be logged properly.")
output.log
2026-06-27 13:57:02,390 root INFO Processing item 0
2026-06-27 13:57:02,421 root INFO Processing item 1
2026-06-27 13:57:02,421 root INFO tqdm[Processing] done: 2/2 (100.0%), elapsed 0.1s, 32.95 it/s, ETA 0.0s
2026-06-27 13:57:02,442 root INFO Nested step outer=0 inner=0
2026-06-27 13:57:02,482 root INFO tqdm[Inner 0] done: 3/3 (100.0%), elapsed 0.1s, 49.25 it/s, ETA 0.0s
2026-06-27 13:57:02,483 root INFO Completed outer=0
2026-06-27 13:57:02,504 root INFO Nested step outer=1 inner=0
2026-06-27 13:57:02,544 root INFO tqdm[Inner 1] done: 3/3 (100.0%), elapsed 0.1s, 49.56 it/s, ETA 0.0s
2026-06-27 13:57:02,545 root INFO Completed outer=1
2026-06-27 13:57:02,545 root INFO tqdm[Outer] progress: 2/2 (100.0%), elapsed 0.1s, 16.19 it/s, ETA 0.0s
2026-06-27 13:57:02,545 root INFO tqdm[Outer] done: 2/2 (100.0%), elapsed 0.1s, 16.19 it/s, ETA 0.0s
2026-06-27 13:57:02,546 root INFO from print statement
2026-06-27 13:57:02,546 root INFO multiple lines
2026-06-27 13:57:02,546 root INFO from print statement 2
2026-06-27 13:57:02,546 root DEBUG Single line
2026-06-27 13:57:02,546 root DEBUG Multiple lines:
2026-06-27 13:57:02,546 root DEBUG next line
2026-06-27 13:57:02,546 root DEBUG Another single line
2026-06-27 13:57:02,546 root DEBUG Multiple lines:
2026-06-27 13:57:02,546 root DEBUG next line
2026-06-27 13:57:02,546 root DEBUG next line 2
2026-06-27 13:57:02,546 root WARNING Warning message
2026-06-27 13:57:02,546 root WARNING with multiple lines
2026-06-27 13:57:02,546 root WARNING and should be logged properly.
2026-06-27 13:57:02,546 root ERROR Error message
2026-06-27 13:57:02,546 root ERROR with multiple lines
2026-06-27 13:57:02,546 root ERROR and should be logged properly.
2026-06-27 13:57:02,547 test_logger2 INFO Logger2 info message
2026-06-27 13:57:02,547 test_logger2 INFO with multiple lines
2026-06-27 13:57:02,547 test_logger2 INFO and should be logged properly.
2026-06-27 13:57:02,547 root ERROR Uncaught exception
2026-06-27 13:57:02,547 root ERROR Traceback (most recent call last):
2026-06-27 13:57:02,547 root ERROR File "/home/npu-tao/micromamba/envs/hipporag/lib/python3.10/runpy.py", line 196, in _run_module_as_main
2026-06-27 13:57:02,547 root ERROR return _run_code(code, main_globals, None,
2026-06-27 13:57:02,547 root ERROR File "/home/npu-tao/micromamba/envs/hipporag/lib/python3.10/runpy.py", line 86, in _run_code
2026-06-27 13:57:02,547 root ERROR exec(code, run_globals)
2026-06-27 13:57:02,547 root ERROR File "/media/npu-tao/disk4T/jason/logging-tee/examples/demo.py", line 41, in <module>
2026-06-27 13:57:02,547 root ERROR raise ValueError("This is an error message\nwith multiple lines\nand should be logged properly.")
2026-06-27 13:57:02,547 root ERROR ValueError: This is an error message
2026-06-27 13:57:02,547 root ERROR with multiple lines
2026-06-27 13:57:02,547 root ERROR and should be logged properly.
Contributing
Increase version in pyproject.toml file.
Modify the src folder.
If using logging_tee in other repository
export PYTHONPATH=<path-to-folder>/src:$PYTHONPATH
python -c "import logging_tee; print(logging_tee)"
If using logging_tee in this repository
export PYTHONPATH=src/:$PYTHONPATH
python -c "import logging_tee; print(logging_tee)"
Run the test
python -m pytest tests -s
Build the package
python -m pip install build
python -m build
pip install dist/*.whl
python -c "import logging_tee; print(logging_tee)"
Upload to TestPyPI first
python -m pip install twine
python -m twine upload --repository testpypi dist/*
python -m pip install --index-url https://test.pypi.org/simple logging-tee
Upload to PyPi
python -m twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logging_tee-1.0.5.tar.gz.
File metadata
- Download URL: logging_tee-1.0.5.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a29847ba10e54cd23b9ca4b6acdc63717935e90e880cd8afad9cd3817ea0e6ed
|
|
| MD5 |
84c6ce0110c26d831e0fbfc4e4927d95
|
|
| BLAKE2b-256 |
bb988c5d3f9f7184bc0eb6275dfbe73e7a39181cf2162d43a7706990784da3e4
|
Provenance
The following attestation bundles were made for logging_tee-1.0.5.tar.gz:
Publisher:
pypi.yml on jasonrichdarmawan/logging-tee
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logging_tee-1.0.5.tar.gz -
Subject digest:
a29847ba10e54cd23b9ca4b6acdc63717935e90e880cd8afad9cd3817ea0e6ed - Sigstore transparency entry: 1977512572
- Sigstore integration time:
-
Permalink:
jasonrichdarmawan/logging-tee@1cf26031cf8e2013150d3a2c4d7c48c03bfef2b1 -
Branch / Tag:
refs/tags/v1.0.5 - Owner: https://github.com/jasonrichdarmawan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@1cf26031cf8e2013150d3a2c4d7c48c03bfef2b1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file logging_tee-1.0.5-py3-none-any.whl.
File metadata
- Download URL: logging_tee-1.0.5-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c369998720700ae1986b1539e6fb3b1f728e718c0d8df34a84cfd59c60b5386
|
|
| MD5 |
05762e8a32d0415407a3ecdb63f456b0
|
|
| BLAKE2b-256 |
5bde7a71b86968fae173bdb17c1a29e44b251f7becf477672c80827b3ed05e6c
|
Provenance
The following attestation bundles were made for logging_tee-1.0.5-py3-none-any.whl:
Publisher:
pypi.yml on jasonrichdarmawan/logging-tee
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logging_tee-1.0.5-py3-none-any.whl -
Subject digest:
9c369998720700ae1986b1539e6fb3b1f728e718c0d8df34a84cfd59c60b5386 - Sigstore transparency entry: 1977512757
- Sigstore integration time:
-
Permalink:
jasonrichdarmawan/logging-tee@1cf26031cf8e2013150d3a2c4d7c48c03bfef2b1 -
Branch / Tag:
refs/tags/v1.0.5 - Owner: https://github.com/jasonrichdarmawan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@1cf26031cf8e2013150d3a2c4d7c48c03bfef2b1 -
Trigger Event:
release
-
Statement type: