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,DEBUGwith highlight. - Log2File: Fully automatic logging to file, with various options for customization.
- Pretty Printing: Pretty print variables like arrays and dictionaries.
- Tables: Log datasets via CLI colored tables with headers and autosizing.
- 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
Log To File
from loggerric import LogToFile, LogToFileLevel
LogToFile.set_dump_location('C:/Users/MyCoolUsername/Desktop', 'important_log') # Don't include the extension
# Control file logging from anywhere
LogToFile.start_logging()
LogToFile.stop_logging()
# Decide what should be logged to file
LogToFile.enable(LogToFileLevel.INFO, ...)
LogToFile.disable(LogToFileLevel.TIMER, ...)
Logging
from loggerric import Log, LogLevel
# Pretty print dictionaries or arrays, including subdicts
Log.pretty_print({ 'name': 'John Doe' }, indent=4)
# Print out a formatted table
headers = ['Item', 'Stock', 'Price']
rows = [('Cola', '25', '$2.99'), ('GPU', '3', '$995.00'), ('Feather', '2,500', '$0.29')]
Log.table(headers, rows, table_name='Store Items')
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
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
loggerric-1.4.2.tar.gz
(11.0 kB
view details)
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
loggerric-1.4.2-py3-none-any.whl
(12.6 kB
view details)
File details
Details for the file loggerric-1.4.2.tar.gz.
File metadata
- Download URL: loggerric-1.4.2.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
557eea3eca520eaee4e1ced2749afcad5c62b68cb1a1f7eb633939d667123bba
|
|
| MD5 |
c2f8745f8c4ba24733033444b270987d
|
|
| BLAKE2b-256 |
a5ea1ff8ddec8a3d53b3455a447b8f2ae0981430a7e562ff8421a3bbf57627e8
|
File details
Details for the file loggerric-1.4.2-py3-none-any.whl.
File metadata
- Download URL: loggerric-1.4.2-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7dbfc56e07e07bf743251f2c0a9e49ea415d94b89d9a3732d9fd58a4f6fbee6
|
|
| MD5 |
afd194e2fb4f4add983bf3d2ddc121dc
|
|
| BLAKE2b-256 |
6a16cdf2c8937fc0853b1d9744d5898ab9dc90660b72b34979f47224a95f1b76
|