A lightweight modular logging framework
Project description
SmartLogger
A lightweight modular logging framework built in Python.
Features
- Modular logging architecture
- Colorized console output (automatic based on log level)
- Multiple log levels (DEBUG, INFO, WARNING, ERROR)
- JSON Formatter for structured logging
- Log rotation by size (
FileHandler) and daily time rotation (TimeRotatingFileHandler) - Custom log format templates
- Exception logging
Installation
Clone the repository and install: pip install -e .
Usage
from smartlogger import Logger
from smartlogger.handlers import ConsoleHandler, TimeRotatingFileHandler
from smartlogger.formatter import Formatter, JSONFormatter
from smartlogger.levels import DEBUG
# Basic Colorized Console Logging
formatter = Formatter("[{time}] [{level}] {message}")
log = Logger(level=DEBUG, formatter=formatter)
log.add_handler(ConsoleHandler(color=True))
log.debug("Tracing execution...")
log.info("Application started")
# Advanced: JSON Logging to a Daily Rotating File
json_log = Logger(level=DEBUG, formatter=JSONFormatter())
json_log.add_handler(TimeRotatingFileHandler("logs/app"))
json_log.error("Database connection failed")
Example Outputs
Console (Colorized automatically)
[2026-05-14 12:00:01] [DEBUG] Tracing execution...
[2026-05-14 12:00:01] [INFO] Application started
JSON Log File (logs/app-2026-05-14.log)
{"time": "2026-05-14 12:00:02", "level": "ERROR", "message": "Database connection failed"}
Architecture
'''
User Code
↓
Logger
↓
Formatter
↓
Handlers
↓
Console / File Output
'''
Project Structure
''' smartlogger/ │ ├── logger.py ├── formatter.py ├── handlers.py ├── levels.py └── init.py '''
Author
Aman Gupta
GitHub: https://github.com/aman-coder-005
Future Improvements
- Additional log handlers (database, network)
- Configurable log levels
- Asynchronous logging
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 smartlogger_aman-0.1.0.tar.gz.
File metadata
- Download URL: smartlogger_aman-0.1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bede6b7ad764ac746209e716b00de472d4b8255d96b3b6cfe1bd3fb7ed97a1b8
|
|
| MD5 |
64c2954e799c977345d448ae5ff8175b
|
|
| BLAKE2b-256 |
630ffaa08c8ee24bb8be755a3abb1642c2eb115c240865a7d51a68ab56469bc2
|
File details
Details for the file smartlogger_aman-0.1.0-py3-none-any.whl.
File metadata
- Download URL: smartlogger_aman-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6daf4b7aca3311fed55c82efa2fe1e254cbaaa342ac7f45be29a676d60dcdf99
|
|
| MD5 |
4b6f84603716e0e22564ca6ffb15d405
|
|
| BLAKE2b-256 |
9a1bfe20067334fd02034f21fbd20e8cf73f835440f6c0f76601279a7dc69677
|