A Python package that provides ready-to-use logging configuration with enhanced formatters, and automatic directory creation. Simplifies logging setup with sensible defaults while supporting custom configurations.
Project description
default_logging

A Python package that provides ready-to-use logging configuration with enhanced formatters, and automatic directory creation. Simplifies logging setup with sensible defaults while supporting custom configurations.
Features
- Millisecond-precision timestamps in log output.
- Timezone-aware formatting (local or UTC with 'Z' suffix).
- YAML-based logging configuration for easy customization.
- Rotating file handler and console logging out-of-the-box.
- Automatic log directory creation for file handlers.
Usage
- Import and configure logging:
from default_logging import configure_logging
configure_logging()
- (Optional) Use your own config:
configure_logging(config_path="path/to/your_logging_config.yaml")
Example
from default_logging import configure_logging
import logging
configure_logging()
logger = logging.getLogger(__name__)
logger.info("Hello, world!")
Logging Configuration
The default configuration is defined in default_logging/logging_config.yaml:
- Formatters:
simple: UTC timestamps, millisecond precision.simple_with_trace_context: Adds OpenTelemetry trace info to each log line.
- Handlers:
console: Logs to stdout.rotating_file: Logs tologs/app.logwith rotation.
- Root logger:
- Level:
DEBUG - Handlers: both console and file.
- Level:
You can customize the YAML config or provide your own.
MillisecondFormatter
Custom formatters in default_logging/millisecond_formatter.py provide:
%ffor milliseconds%zfor timezone offset (+HH:MM,-HH:MM, orZfor UTC)
OpenTelemetry Integration
The package is compatible with OpenTelemetry.
Check example usage here, and then execute opentelemetry-instrument --traces_exporter=console --metrics_exporter=none --logs_exporter=none python app.py with formatter configured to simple_with_trace_context to see logs that contain trace IDs and span IDs.
2026-01-01T00:00:00.389Z INFO [__main__] [app.py:15] [trace_id=2435d597af884b3104d8ca18a310913d span_id=ffc6c2f74d71a441 trace_sampled=True] - Hello with OpenTelemetry trace context!
License
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 default_logging-0.5.1.tar.gz.
File metadata
- Download URL: default_logging-0.5.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.12 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eff0acb45b60e621893d0dd0b16309eecde253a0a52554d89b6df7fe28b95473
|
|
| MD5 |
921c06a6473fc8a19f869cd31bb141be
|
|
| BLAKE2b-256 |
6186f768164150589d5b03af42246b63549c6e1d2d4f30269b07cbd4949a53be
|
File details
Details for the file default_logging-0.5.1-py3-none-any.whl.
File metadata
- Download URL: default_logging-0.5.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.12 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
beb9b50ac3947faa257f3b5dea737c63add1d9ed493746d8867583cc0d8842c7
|
|
| MD5 |
b81b4b9fb600d04e418d282bb2c3f3f1
|
|
| BLAKE2b-256 |
6b84b32be4374cea4338d5fca1669075cfbb6497d02fd5252df0d3b12d11c643
|