Skip to main content

A lean & hackable rich logger and print function.

Project description

print-on-steroids :weight_lifting_man:

Build Status Conda Version PyPI Version Code Size Code Style Linter

A lean and hackable rich logger and print function.

Installation

pip install print-on-steroids
conda install -c conda-forge print-on-steroids

Features

  • Support for logging only on rank zero in distributed setups (e.g. Deep Learning)
  • Gracefully handles tqdm and tqdm.rich progress bars (no annoying leftover progress bars anymore!)
  • Rich meta-information for free like timestamps and originating line of code with clickable link
  • Easy switching between dev and package modes when publishing packages to PyPI (cleaner logs without clutter)

Usage

from print_on_steroids import print_on_steroids as print, logger

# Enjoy enhanced print with optional log levels, timestamp, and originating line of code
print("It's like", "your regular", "Python print function", "but better", level="success")

# Logging with multiple processes - avoid terminal clutter 
print("Gets printed", rank=0, rank0=True)
print("Doesn't get printed", rank=1, rank0=True)

# Full-fledged logger object out-of-the-box
logger.log("This", "is", "cool", level="info")
# or directly:
logger.info("This", "is", "cool")
logger.warning("This", "is", "dangerous")
logger.error("This", "is", "fatal")
...

# Easy setup for distributed setting:
logger.config(rank=RANK, print_rank0_only=True)
# Afterwards, the rank is remembered and does not need to be passed again
logger.success("Dataset processing finished!") # <-- this now prints only on rank zero

# For cleaner logs when publishing a package, use this:
logger.config(mode="package", package_name="torch")

# Gracefully handles tqdm
from tqdm import tqdm
for i in tqdm(range(42), desc="This works!"):
    sleep(1)
    logger.success("Work done:", i)
    print_on_steroids("Work done:", i)

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

print-on-steroids-1.1.0.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

print_on_steroids-1.1.0-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

Supported by

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