Opinionated Python logging
Project description
sysentropy
Opinionated Python logging for the recurring problem of: "I just need a decent logger, why am I formatting timestamps by hand again?"
sysentropy is a small Python library that writes plain logs to disk, colored logs to stdout, and gives you reusable timestamp, timing, and exception helpers so you can stop rebuilding the same logging glue in every project.
How This Repo Happened
This repo exists because writing the same logging setup in every project gets old fast.
One day it is:
- "I'll just do a tiny logger wrapper."
- then "I want colors."
- then "I want a logfile too."
- then "why is this handler duplicated?"
- then "what was that timestamp format again?"
At that point the only rational response was obviously to make a library about it.
So this is the result: a lightweight package extracted from that exact cycle of mild annoyance, repeated enough times to become a design requirement. Very noble. Very serious. Entirely unnecessary until it suddenly isn't.
What It Does
- plain logs on disk
- colored logs on stdout
- a small API built on top of the standard
loggingmodule - a reusable timestamp helper for logfile names and other boring-but-common cases
- a timing decorator for quick execution-time logging
- lightweight helpers for timed blocks and exception logging
Features
- Linux-kernel-inspired level colors for console output
- separate stdout and file formatters
- simple
get_logger()entrypoint - optional directory creation for file logging
- handler reuse to avoid duplicate output
- a configuration object that leaves room for future expansion
- a
timestamp()helper that returnsYYYYMMDD_HHMMSS - a
timing()decorator that logs function runtime - a
time_block()context manager for inline timing - a
log_exceptions()helper that logs tracebacks before re-raising - automatic color detection for TTY vs redirected output
Install
pip install sysentropy
Quick start
from sysentropy import get_logger, log_exceptions, time_block, timestamp, timing
logger = get_logger("demo", log_file=f"logs/demo-{timestamp()}.log")
@timing(logger=logger)
@log_exceptions(logger=logger)
def do_work() -> None:
with time_block("startup", logger=logger):
logger.info("service started")
logger.debug("debug message")
do_work()
logger.warning("disk usage high")
logger.error("request failed")
logger.critical("system halted")
Default output style:
2026-04-01 22:00:00 INFO : service started
2026-04-01 22:00:00 WARNING : disk usage high
2026-04-01 22:00:00 ERROR : request failed
Timestamp Helper
If you only need the timestamp format, import it directly:
from sysentropy import timestamp
filename = f"run-{timestamp()}.log"
It returns values like:
20260401_223735
Timing Helper
Use timing() as a decorator when you want a quick runtime measurement in your logs:
from sysentropy import get_logger, timing
logger = get_logger("demo")
@timing(logger=logger, label="expensive task")
def expensive_task() -> None:
...
It logs lines like:
2026-04-02 09:15:00 INFO : expensive task completed in 0.012384s
Timed Blocks
Use time_block() when you only want to time one section of a function:
from sysentropy import get_logger, time_block
logger = get_logger("demo")
with time_block("database warmup", logger=logger):
...
Exception Logging
Use log_exceptions() to log tracebacks before the exception keeps propagating:
from sysentropy import get_logger, log_exceptions
logger = get_logger("demo")
@log_exceptions(logger=logger)
def run_job() -> None:
raise RuntimeError("boom")
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
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
File details
Details for the file sysentropy-0.1.1.tar.gz.
File metadata
- Download URL: sysentropy-0.1.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0718052cf28bdbf2bf4b6c7fc4307adbf8a3eedbc37c8f48722261ad7829373d
|
|
| MD5 |
4c3a65f07276d3105ec999df0ea84124
|
|
| BLAKE2b-256 |
4ef057ed10d0a10e93979fad6a817103683a587c0546ec5018a9289ffc25b2e8
|
File details
Details for the file sysentropy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sysentropy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d959176bba24e47c486c0e19d88e655047f87c73aed2bac169121f1b3cc97c31
|
|
| MD5 |
f2946383f9f99ec80f8f03baab1ed76d
|
|
| BLAKE2b-256 |
822a1dcc384b5358afb10f5148dffecf3fed37aa15cfab075b47c1dcddb71e38
|