Skip to main content

A logging utility for Python. Developed for personal use.

Project description

loggerric

loggerric is a lightweight Python utility library providing advanced logging, for CLI applications. It offers colorful, formatted output to make debugging, logging and tracking easier.


Features

  • Logging: Structured logging with levels: INFO, WARN, ERROR, DEBUG with highlight.
  • Pretty Printing: Pretty print variables like arrays and dictionaries.
  • Progress Bars: Real-time CLI progress bars with ETA calculations.
  • Prompts: Interactive user input with optional choices and defaults.
  • Timers: Measure execution time of code snippets.
  • Timestamps: Optional, can be used independently, and support rolling differences.

Installation

pip install loggerric

Usage

Logging

from loggerric import Log, LogLevel

Log.pretty_print({ 'name': 'John Doe' }, indent=4)

Log.info("This is an info message", "This is also a message", ..., highlight=['This', 'message'])
Log.warn("This is a warning", ..., highlight='warning')
Log.error("This is an error", ..., quit_after_log=True, highlight='error')
Log.debug("This is a debug message", ..., highlight='debug')

# Enable or disable specific logging levels
Log.disable(LogLevel.DEBUG, LogLevel.WARN, ...)
Log.enable(LogLevel.DEBUG, ...)

Progress Bar

from loggerric import ProgressBar
from time import sleep

end_val = 50
bar = ProgressBar(end_value=end_val, name='Downloading', bar_length=40)
for i in range(1, end_val + 1):
    sleep(0.05)
    bar.update(i)

Prompt

from loggerric import prompt

# Simple input
name = prompt("Enter your name")

# Input with options
choice = prompt("Choose a letter", options=['a', 'b', 'c'], default='b', loop_until_valid=True, case_sensitive=False)

Timer

from loggerric import Timer
from time import sleep

with Timer(name='Calculation Timer'):
    sleep(1.5)

Timestamp

from loggerric import Timestamp, Log

Timestamp.set_format('{HH}:{MM}:{SS}.{MS} T+{dm}ms')

Log.info(Timestamp.get())

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

loggerric-1.3.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

loggerric-1.3.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file loggerric-1.3.0.tar.gz.

File metadata

  • Download URL: loggerric-1.3.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for loggerric-1.3.0.tar.gz
Algorithm Hash digest
SHA256 1304e97e08dd7020be98f06ff05f88f6760dad993435b66b95f93cb865a0a89e
MD5 23b66c37829f4f5c8593ad063319591b
BLAKE2b-256 0f11b4889fedcfa03c93539a8171262c5e2deb9a2491857d929068b8061e56b9

See more details on using hashes here.

File details

Details for the file loggerric-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: loggerric-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for loggerric-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d741ec0ecd3883b0a896cd312e4aa958239ed3e1e585f33b5009f53c262f3952
MD5 a58982ce4effaa73bebf940a5d795cd5
BLAKE2b-256 b984b91d0f46d7edb5882e3e5b3f06d4050838b4514fe9b5f804201dc3e8d9d1

See more details on using hashes here.

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