pyloggy
A tiny, dependency-free Python logger for clean CLI output. It gives you readable level prefixes, optional icons, ANSI colors, and simple style presets without pulling in heavy frameworks.
What It Does
- Provides five practical methods:
log,info,ok,warn,err. - Includes
StopwatchandProgressTrackerfor timers, ETA, and progress bars. - Uses style presets to control labels, icons, and color output.
- Writes normal output to
stdoutand errors tostderr. - Auto-adjusts formatting for terminals and supports color-related env flags.
Install & Use
Install
pip install "git+https://github.com/SamuelDBines/pyloggy.git"
Quick Start
from loggy import Log
log = Log(debug=True, verbose=True, style="cli")
log.log("Starting")
log.info("Loading config")
log.ok("Ready")
log.warn("Cache is stale")
log.err("Connection failed")
How It Works
debug=Trueenableslog(...).verbose=Trueenablesinfo(...)(also enabled bydebug=True).ok/warn/errare always emitted.- Colors are controlled by
use_color, TTY detection,NO_COLOR, andFORCE_COLOR.
Color Setup
Built-in levels map to straightforward semantic colors:
For fully plain output in CI or redirected logs, set NO_COLOR=1.
To force colors in non-TTY environments, set FORCE_COLOR=1.
Config Builder
Pick your setup and generate copy/paste code.
Truecolor preference sets terminal env hints (`COLORTERM=truecolor` on Linux/macOS, safe defaults on Windows). Color pickers generate `hex_to_ansi(...)` overrides in Python.
Code updates live as you edit.
Reusable Package API
defaultclassicminimalcliemojiplain
from loggy import (
Log, LogStyle, STYLES, get_style,
Stopwatch, ProgressTracker, ProgressSnapshot, time_call,
)
Start with a preset and override only what you need:
from loggy import Log, get_style
style = get_style("cli", warn_label="[warning]", warn_icon="⚠")
log = Log(style=style)
Timer + Progress Example
from loggy import ProgressTracker, Stopwatch
with Stopwatch() as sw:
tracker = ProgressTracker(total=3)
for _ in range(3):
tracker.advance()
print(tracker.render(width=12))
print("done in", Stopwatch.format_seconds(sw.elapsed))
See the repository README for complete package docs and publishing workflow.