A flexible logging utility with JSON support and timezone awareness
Project description
Setlogging
A flexible Python logging utility with JSON support and timezone awareness.
Author
- Name: Jie Yan
- Contact: kiki3890528@gmail.com
Features
- JSON and plain text log formats
- Log file rotation with size limits
- Console output options
- Timezone-aware logging
- Customizable formatting
- Type-safe configuration
Installation
pip install setlogging
Usage
from setlogging import get_logger
# Basic logging
logger = get_logger()
logger.info("Basic log message")
# JSON logging with indentation
logger = get_logger(json_format=True, indent=2)
logger.info("Structured logging")
# Custom file and rotation
logger = get_logger(
log_file="/tmp/app.log",
max_size_mb=10, # 10MB
backup_count=5
)
# Disable console output
logger = get_logger(console_output=False)
logger.info("This will not be printed to the console")
Project Structure
setlogging/
├── src/
│ └── setlogging/
│ ├── __init__.py
│ └── logger.py
├── tests/
│ ├── __init__.py
│ └── test_logger.py
├── pyproject.toml
├── README.md
└── LICENSE
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
log_level |
int | DEBUG |
Logging level |
log_file |
str | app.log or app_json.log |
Log file path |
max_size_mb |
int | 25 |
Max file size in MB before rotation |
backup_count |
int | 7 |
Number of backup files |
console_output |
bool | True |
Enable console logging |
log_format |
str | None |
Custom log format string |
date_format |
str | None |
Custom date format string |
json_format |
bool | False |
Enable JSON formatting |
indent |
int | None |
JSON indentation level |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
setlogging-0.3.4.tar.gz
(94.4 kB
view details)
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 setlogging-0.3.4.tar.gz.
File metadata
- Download URL: setlogging-0.3.4.tar.gz
- Upload date:
- Size: 94.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e95256fd6d0096156e71c3f92aa30600cb47d6a39cb39787b3f92533e2e26c6b
|
|
| MD5 |
c1b066f5f202725b7bf053ba65376631
|
|
| BLAKE2b-256 |
14d16f20e70eabd9d2702bcfa4957b01415fa22e470f67a18843b7d111495028
|
File details
Details for the file setlogging-0.3.4-py3-none-any.whl.
File metadata
- Download URL: setlogging-0.3.4-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb6416e459eaa826c14519f1a733b31a5abba7defed7a383634e6a3eb31272f4
|
|
| MD5 |
744a4c65912067910f9ce5ec7bcf9171
|
|
| BLAKE2b-256 |
d47d7d08223162f91a9a3375651b0250cc4d2b2304743bc1b1d1bded4049faeb
|