Skip to main content

Tune your logs

tuning icon

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 TRACE and SUCCESS)
  • Colorful console output, with optional information: timestamp and path (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 tuning does 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

tuning icon

Metadata

Release files for 2ning 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for 2ning 1.0.0
File Size Uploaded
2ning-1.0.0.tar.gz 29.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for 2ning 1.0.0
File Interpreter ABI Platform
2ning-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.0 kB

Release files / 2ning-1.0.0.tar.gz

Download URL 2ning-1.0.0.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b1c3db169202a79a9e6f0c5264a22c01b29068d4894c5b8ef4da1e1cc88cd920
BLAKE2b-256 checksum
How to use checksums
e91fd4dc43b7b2474b7a4c26769f393e10540ddaaeb875cec10b68c8500c4644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / 2ning-1.0.0-py3-none-any.whl

Download URL 2ning-1.0.0-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26c4655f0923890c3580c8c20e12cd7f0fddfa15cb55c750f48bf83bd8354311
BLAKE2b-256 checksum
How to use checksums
fa73d855ef60014187a4cafac6272452c1e7e1575a124887ef21f7eaf8e886f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page