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 python app.py with formatter simple_with_trace_context to see logs that contain trace and span IDs.
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.0.tar.gz.
File metadata
- Download URL: default_logging-0.5.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.11 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ee28acc5b97d46955e1152a4145ac990520372c63208e20badf5ae8d4c6fc3d
|
|
| MD5 |
3602f2139be6d08010ca2f9eeee36c54
|
|
| BLAKE2b-256 |
b10f9bf5c45d71c4b6b62b5f82ba82fb7abedc0945fc7df92f18c98b2d7a63a0
|
File details
Details for the file default_logging-0.5.0-py3-none-any.whl.
File metadata
- Download URL: default_logging-0.5.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.11 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8353ecef5867e758076bfe56f1267df21a16c765541dfcccddb98fc4488d9240
|
|
| MD5 |
b2aed430e6ae5edec3be605308642d84
|
|
| BLAKE2b-256 |
396fe46691597355e63aefd690b8ec085080024a775deadafff70c54466c32f2
|