Skip to main content

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(__name__)

    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.")
    raise ValueError("This is an error message\nwith multiple lines\nand should be logged properly.")

Contributing

Build the package

python -m pip install build
python -m build
python 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/*

Upload to PyPi

python -m twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logging_tee-1.0.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logging_tee-1.0.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file logging_tee-1.0.2.tar.gz.

File metadata

  • Download URL: logging_tee-1.0.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for logging_tee-1.0.2.tar.gz
Algorithm Hash digest
SHA256 861d07bc8833d05977c200ba9c146f084636c65ea2a45352227cb1985bbab812
MD5 e0595da2598fe354df76fc7f5e584174
BLAKE2b-256 189fa4f5c72a8dbe9bd0a4ecdcebd059371abcc92be10effc22cee2df8d77c98

See more details on using hashes here.

Provenance

The following attestation bundles were made for logging_tee-1.0.2.tar.gz:

Publisher: pypi.yml on jasonrichdarmawan/logging-tee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logging_tee-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: logging_tee-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for logging_tee-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 213d1488f0fc6f5bb0f50a34b541eef30650f4e4690bbc4c877fab044af81149
MD5 12dd34b3466369156943c06c721f74ad
BLAKE2b-256 b8210f674ab6ccfa3d6a22f383c74496102f906cd16b11956b3a0e4d4c683a77

See more details on using hashes here.

Provenance

The following attestation bundles were made for logging_tee-1.0.2-py3-none-any.whl:

Publisher: pypi.yml on jasonrichdarmawan/logging-tee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page