Colorful and customizable logging module for CLI applications.
Project description
Tune your logs
tuning is a colorful and customizable dual-logging module for CLI applications. Emojis included 😉.
The idea is simple, display human-readable and colorful terminal logs, while keeping file logs detailed and sober.
It builds on stdlib logging and Rich, so you can use it as usual:
- logging via named functions:
logger.my_custom_lvl() - natural language defined styles:
bold italic white on red
Features
Easy to use
- Stdlib-like root logger configuration through
basicConfig(), including rotating logs. - YAML-driven configuration (we got your back with the defaults)
Fully customizable
- Logging levels: icon, symbol, and style. (already added
TRACEandSUCCESS) - Colorful console output, with optional information:
timestampandpath(caller file). - Styled interactive prompts, with default value:
logger.prompt(...) - Custom app banners through
banner(...) - Inside-of-the-box: experimental display mode which encloses console records into boxes. Beautiful, but
Optional extras are available for CLI and TUI integrations, but
tuningdoes not wrap Typer or Textual.
Install
pip install 2ning
For local development:
git clone https://github.com/octanima-labs/tuning
cd tuning
pip install -e ".[dev,cli,tui,docs]"
Quick Start
import tuning
logger = tuning.getLogger(__name__)
logger.info("application started")
logger.success("everything looks good")
name = logger.prompt("Your name?")
logger.info("hello %s", name)
This zero-config path installs packaged console defaults lazily on first use. Configure logging explicitly when you want predictable startup behavior:
import tuning
tuning.basicConfig(
level="INFO",
show_time=True,
datefmt=tuning.ISO_FORMAT,
)
logger = tuning.getLogger(__name__)
logger.info("configured output")
Use show_level=False when console output should contain only the message.
Add a runtime-only custom level:
tuning.addLevel(7, "MY_CUSTOM_LEVEL", symbol="MC", style="bright_blue")
logger = tuning.getLogger(__name__)
logger.my_custom_level("custom runtime output")
Print a custom app banner from banners.txt:
import tuning
tuning.banner()
With no path, banner() searches upward from the calling file for
banners.txt. Each section starts with a strict lowercase marker such as
### ansi_shadow.
Customize rendering with Rich styles:
tuning.banner(
name="ansi_shadow",
border_style="bright_cyan",
text_style="bold bright_magenta",
background_style="on black",
padding=(0, 2),
box="HEAVY",
)
Files And YAML
Use a file handler:
tuning.basicConfig(filename="app.log", level="INFO")
Use rotating file logs:
tuning.basicConfig(
filename="app.log",
max_bytes="10 MB",
backup_count=5,
)
Export a full starter YAML config into your project:
import tuning
config_path = tuning.export()
Load YAML configuration:
tuning.basicConfigFromYaml("tuning.yml", force=True)
Documentation
Development
Common contributor commands and documentation build steps live in Development.
The short version:
./.venv/bin/python -m pytest
./.venv/bin/ruff check .
./.venv/bin/mypy tuning tests
./.venv/bin/sphinx-build -W -b dirhtml docs site
License
tuning is distributed under the MIT license.
We 💙 CLI
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 2ning-1.0.0.tar.gz.
File metadata
- Download URL: 2ning-1.0.0.tar.gz
- Upload date:
- Size: 29.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1c3db169202a79a9e6f0c5264a22c01b29068d4894c5b8ef4da1e1cc88cd920
|
|
| MD5 |
edc0ab7a046be7e6902579f869e1365b
|
|
| BLAKE2b-256 |
e91fd4dc43b7b2474b7a4c26769f393e10540ddaaeb875cec10b68c8500c4644
|
File details
Details for the file 2ning-1.0.0-py3-none-any.whl.
File metadata
- Download URL: 2ning-1.0.0-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26c4655f0923890c3580c8c20e12cd7f0fddfa15cb55c750f48bf83bd8354311
|
|
| MD5 |
4fea216fc98da9921d197efa3bcf1e21
|
|
| BLAKE2b-256 |
fa73d855ef60014187a4cafac6272452c1e7e1575a124887ef21f7eaf8e886f3
|