simpac-logger
A Python logger you set up in one line: colored console output by level plus a
daily log file under logs/, with optional size-based rotation. Standard library only,
no dependencies. Maintained by the SIMPAC AI Lab.
from simpac_logger import get_logger
log = get_logger(__name__)
log.debug("detailed information") # blue
log.info("general information")
log.success("task completed") # green
log.warning("something to watch") # orange
log.error("something failed") # red
log.critical("fatal error") # bold white on red
Console:
15:04:12 | DEBUG | myapp | detailed information
15:04:12 | INFO | myapp | general information
15:04:12 | SUCCESS | myapp | task completed
15:04:12 | WARNING | myapp | something to watch
15:04:12 | ERROR | myapp | something failed
15:04:12 | CRITICAL | myapp | fatal error
logs/2026-09-07.log (no color codes):
2026-09-07 15:04:12.031 | DEBUG | myapp | detailed information
2026-09-07 15:04:12.031 | INFO | myapp | general information
2026-09-07 15:04:12.032 | SUCCESS | myapp | task completed
...
Installation
pip install simpac-logger
In requirements.txt:
simpac-logger>=0.2.0
Usage
get_logger() arguments
| Argument | Default | Description |
|---|---|---|
name |
"simpac" |
Logger name, usually __name__. Calling again with the same name does not add handlers; it only updates the levels |
level |
"DEBUG" |
Minimum level for console output, as a string or an int |
log_dir |
"logs" |
Directory for log files, created if missing. Relative paths are resolved against the current working directory. Can also be set with the SIMPAC_LOG_DIR environment variable |
to_file |
True |
False disables the file handler |
file_level |
"DEBUG" |
Minimum level written to the file |
color |
None |
None auto-detects; True/False forces the choice |
stream |
sys.stdout |
Console output stream; pass sys.stderr to switch |
max_bytes |
0 |
Start a new part when the day's file would grow past this many bytes; 0 disables size rotation |
backup_count |
0 |
Rotated parts to keep per day when max_bytes is set; 0 keeps all of them |
# INFO and above on the console, everything in the file, custom directory
log = get_logger("crawler", level="INFO", log_dir="output/logs")
# console only
log = get_logger("quick", to_file=False)
# cap each file at 10 MB and keep at most 5 rotated parts per day
log = get_logger("worker", max_bytes=10 * 1024 * 1024, backup_count=5)
Levels
| Level | Value | Color |
|---|---|---|
| DEBUG | 10 | blue |
| INFO | 20 | default |
| SUCCESS | 25 | green |
| WARNING | 30 | orange |
| ERROR | 40 | red |
| CRITICAL | 50 | bold white on red |
SUCCESS is added by this package. Use level="SUCCESS" to hide INFO messages while
keeping success messages visible.
Color detection
NO_COLORis set: always offFORCE_COLORis set: always onTERM=dumb: off- Jupyter (ipykernel) output stream: on
- Otherwise on only when the stream is a TTY, so colors disappear automatically when piped or redirected
On Windows 10 and later the console's ANSI mode is enabled automatically.
Daily files and size rotation
- File names follow
logs/YYYY-MM-DD.login local time. - A process running past midnight writes subsequent records to the new day's file.
- Multiple runs on the same day append to the same file.
- With
max_bytesset, a file that would grow past the limit is renamed toYYYY-MM-DD.001.log(then.002.logand so on) and a freshYYYY-MM-DD.logis started. The live file always keeps the plain date name, and the numbered parts sort in chronological order, oldest first. backup_countlimits how many numbered parts are kept for each day; the oldest are deleted first. Files from previous days are never deleted.- Add
logs/to your.gitignore.
A busy day with max_bytes set looks like this:
logs/
├── 2026-09-06.log
├── 2026-09-07.001.log # oldest part of the day
├── 2026-09-07.002.log
└── 2026-09-07.log # live file
Working with existing logging code
get_logger() returns a subclass of the standard logging.Logger, so exception(), log(),
filters and extra handlers work as usual. If a logger with the same name was already created
with logging.getLogger(__name__), get_logger(__name__) attaches the handlers and a
success() method to that existing logger. Propagation to the root logger is turned off, so
records are not printed twice when the root logger has handlers of its own.
Limitations
log_diris relative to the current working directory, not to the script. Scripts started from cron or from another directory should pass an absolute path, for examplePath(__file__).resolve().parent / "logs".- Old daily files are never deleted.
backup_countonly limits size-rotated parts within a day; use a scheduled job orlogrotatefor long-term retention. - Several processes writing to the same file are not coordinated: lines may interleave, and a
size rotation done by one process is not seen by the others. Give each process its own
log_dir. - Handlers are the standard blocking ones from
logging; there is no asynchronous mode.
Development
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest
python examples/demo.py
Release steps for maintainers are in CONTRIBUTING.md.
License
MIT
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 simpac_logger-0.2.0.tar.gz.
File metadata
- Download URL: simpac_logger-0.2.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
852356898cc20dc806ab950b3f2ba5b72e232d6ccac69dbbece7dff7119c352c
|
|
| MD5 |
36d743560a3c343e4aefbf8a3030e18b
|
|
| BLAKE2b-256 |
1c4b0c02b1fe43a01da9431b50d62dc9a704d13f67b0e1128fa46bfc10ced66f
|
Provenance
The following attestation bundles were made for simpac_logger-0.2.0.tar.gz:
Publisher:
publish.yml on simpac-ai-lab/simpac-logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simpac_logger-0.2.0.tar.gz -
Subject digest:
852356898cc20dc806ab950b3f2ba5b72e232d6ccac69dbbece7dff7119c352c - Sigstore transparency entry: 2748687495
- Sigstore integration time:
-
Permalink:
simpac-ai-lab/simpac-logger@eec3d5f6761d2194f0a6013cd070134e91905946 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/simpac-ai-lab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eec3d5f6761d2194f0a6013cd070134e91905946 -
Trigger Event:
push
-
Statement type:
File details
Details for the file simpac_logger-0.2.0-py3-none-any.whl.
File metadata
- Download URL: simpac_logger-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71d6c304fda89c8dd565d40490f834419c1b1243c67ed2dc2c8d120078095e14
|
|
| MD5 |
a38345eb2a2a8afcefcd6000d1c4e492
|
|
| BLAKE2b-256 |
220b6031556bd12ed564d28edd50a098478fb6918bf7ef2e572f58245da2b899
|
Provenance
The following attestation bundles were made for simpac_logger-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on simpac-ai-lab/simpac-logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simpac_logger-0.2.0-py3-none-any.whl -
Subject digest:
71d6c304fda89c8dd565d40490f834419c1b1243c67ed2dc2c8d120078095e14 - Sigstore transparency entry: 2748687526
- Sigstore integration time:
-
Permalink:
simpac-ai-lab/simpac-logger@eec3d5f6761d2194f0a6013cd070134e91905946 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/simpac-ai-lab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eec3d5f6761d2194f0a6013cd070134e91905946 -
Trigger Event:
push
-
Statement type: