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.2.1.tar.gz
(61.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.2.1.tar.gz.
File metadata
- Download URL: setlogging-0.2.1.tar.gz
- Upload date:
- Size: 61.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccf99fdf0d590a8f9cb094cd0b3a8343df0bd5a4dd61a14bcf355f15cf17e610
|
|
| MD5 |
affdb0a65a66e3e3e515aa3e1fd0bc3a
|
|
| BLAKE2b-256 |
7529309b2aa3f42e7d0f6914727b5e62016a2a71c230e297408fa82d9d160b4a
|
File details
Details for the file setlogging-0.2.1-py3-none-any.whl.
File metadata
- Download URL: setlogging-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a2e34aa4e6cf555e091dd6904e59d181aa2c635c5d3bbcea2bf371f1551c944
|
|
| MD5 |
5b9ed7a6850676611a649136d19f0451
|
|
| BLAKE2b-256 |
ae2c05ed99e1b52d58c8d7f134be4132ac595cb6e7aceb69d7610bedf64f5230
|