beauty-log
A lightweight, customizable Python logger with color support, tree-based message formatting, grouping, and file output.
Installation
pip install beauty-log
Requirements
- Python 3.12+
- colorama
Quick Start
from beautylog import Logger
logger = Logger(
tree=["{time}", "{level}", "{message}"],
)
logger.console("Application started")
logger.console("Something went wrong", level="ERROR")
Output:
12:00:01 INFO Application started
12:00:01 ERROR Something went wrong
Usage
Basic Setup
from beautylog import Logger
logger = Logger(
tree=["{time}", "{level}", "{message}"], # defines the output format
)
Log Levels
| Level | Color |
|---|---|
DEBUG |
Cyan |
INFO |
Blue |
SUCCESS |
Green |
WARNING |
Yellow |
ERROR |
Red |
CRITICAL |
Magenta |
logger.console("Loaded config", level="DEBUG")
logger.console("Server started", level="SUCCESS")
logger.console("Disk space low", level="WARNING")
logger.console("Connection failed", level="ERROR")
logger.console("System failure", level="CRITICAL")
Custom Color Scheme
Override the default colors or add custom levels entirely:
from colorama import Fore
logger = Logger(
tree=["{time}", "{level}", "{message}"],
levelColorScheme={
"INFO": Fore.WHITE,
"SUCCESS": Fore.GREEN,
"DB": Fore.CYAN, # custom level
"AUTH": Fore.MAGENTA, # custom level
}
)
logger.console("Query executed", level="DB")
logger.console("User logged in", level="AUTH")
Tree Formatting
The tree parameter defines the structure of each log line. Each element is a segment that supports built-in placeholders:
| Placeholder | Value |
|---|---|
{message} |
The log message |
{time} |
Current time (HH:MM:SS) |
{level} |
Colored level label |
logger = Logger(tree=["[{time}]", "[{level}]", ">>", "{message}"])
# [12:00:01] [INFO] >> Server is running
Variables
Pass custom variables to be substituted anywhere in the tree:
logger = Logger(
tree=["{time}", "[{module}]", "{level}", "{message}"],
variables={"{module}": "database"}
)
logger.console("Connected successfully", level="SUCCESS")
# 12:00:01 [database] SUCCESS Connected successfully
Grouping
Use setGroupLevel() to indent related log messages and visually group them:
logger.console("Starting app", level="INFO")
logger.setGroupLevel(1)
logger.console("Loading config", level="DEBUG")
logger.console("Connecting to DB", level="DEBUG")
logger.setGroupLevel(2)
logger.console("Running migrations", level="DEBUG")
logger.setGroupLevel(1)
logger.console("Ready", level="SUCCESS")
logger.setGroupLevel(0)
logger.console("App started", level="SUCCESS")
Output:
12:00:01 INFO Starting app
12:00:01 DEBUG Loading config
12:00:01 DEBUG Connecting to DB
12:00:01 DEBUG Running migrations
12:00:01 SUCCESS Ready
12:00:01 SUCCESS App started
Saving to File
logger.save("Server started", level="INFO", logFile="app.log")
ANSI color codes are automatically stripped from file output.
log()
Log to both the terminal and a file in one call:
logger.log("User signed up", level="SUCCESS", logFile="app.log")
Timer
Measure and log execution time using the context manager:
with logger.timer("Database query"):
results = db.execute(query)
# logs: Database query took 42.30ms
# Automatically escalate to WARNING if a threshold is exceeded
with logger.timer("API call", warnAfter=200):
response = requests.get(url)
# logs as WARNING if it takes over 200ms
API Reference
Logger(tree, levelColorScheme, variables)
| Parameter | Type | Default | Description |
|---|---|---|---|
tree |
list |
None |
Output format segments |
levelColorScheme |
dict |
Built-in colors | Map of level names to colorama colors |
variables |
dict |
None |
Custom substitution variables |
console(message, level, useBuiltIns)
Print a formatted message to the terminal.
save(message, level, logFile, useBuiltIns)
Write a message to a log file (colors stripped automatically).
log(message, level, logFile)
Print to terminal and write to file.
setGroupLevel(groupLevel)
Set the current indent depth. Accepts any non-negative integer. Raises ValueError for negative values.
timer(label, level, warnAfter)
Context manager that measures execution time and logs the result.
License
This project is licensed under the GNU General Public License v3.0 — see the LICENSE file for details.
Metadata
Release files for beauty-log 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| beauty_log-0.1.2.tar.gz | 34.4 kB | With provenance | Details for beauty_log-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| beauty_log-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for beauty_log-0.1.2-py3-none-any.whl |
Total release size: 64.2 kB
Release files / beauty_log-0.1.2.tar.gz
| Download URL | beauty_log-0.1.2.tar.gz |
|---|---|
| Size | 34.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1b7ab30c41a1e8a80c06ce550faa56f73dc052024a3d52fcb55da717ca45e4c
|
|
BLAKE2b-256 checksum How to use checksums |
b0f783b7f6e7dc7910c81a887866f87ed781210a4854f1332b9852c1842a7c47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / beauty_log-0.1.2-py3-none-any.whl
| Download URL | beauty_log-0.1.2-py3-none-any.whl |
|---|---|
| Size | 29.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
658d937ec3f6c296019044e7adb9ddd288f2a723c9f9088b38ddbc6ef3276c1c
|
|
BLAKE2b-256 checksum How to use checksums |
03189126f6df814f56a0a8f4fd9198883fbc889ff3d58c52d3ecb132fd053687
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logSecurity for beauty-log 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for beauty_log-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.