Skip to main content

A lean & hackable rich logger and print function.

Project description

print-on-steroids :weight_lifting_man:

PyPI Version Code Size Code Style

A lean and hackable rich logger and print function.

Installation

pip install print-on-steroids

Features

  • Easy switching between dev and prod modes for logging and an extra logging mode for publishing packages
  • Rich meta-information for free like timestamps and originating line of code with clickable link
  • Support for logging only on rank zero in distributed setups (e.g. Deep Learning)

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")

# Dev logs can be turned on again like this:
logger.config(mode="dev")

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.0.0.tar.gz (8.5 kB view hashes)

Uploaded Source

Built Distribution

print_on_steroids-1.0.0-py3-none-any.whl (5.7 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