Smart Logger library for Python projects with FastAPI, Flask, and Django support
Project description
Smart Logger
Smart Logger is a Python logging library with FastAPI, Flask, and Django support. It provides UUID-based logs, date/parent_folder structured logs, database metadata storage, and a FastAPI dashboard with filters, real-time monitoring, charts.
Features
-
Multi-framework support: FastAPI, Flask, Django
-
Structured logging: UUID for each log entry
-
Dynamic folder structure:
date/parent_folder/filename.log -
Database metadata storage (default SQLite)
-
SmartLogger class with logging levels:
logger.info()logger.error()logger.warning()logger.critical()logger.debug()
-
FastAPI Dashboard UI:
- Real-time logs
- Filter logs by date, time, UUID, log type
- Bar charts for daily, monthly, yearly log insights
- System info cards and statistics
- Interactive UI with logout functionality
-
Secure: input sanitization, token-based authentication, blacklist token support
-
CLI commands for user management, configuration, and server launch
Installation
pip install smart-logger
Quick Setup (Step by Step)
-
Generate default config file
smart-logger make-smart-logger-default-conf→ This creates a config file in your project folder.
-
Update config file
- Add your database credentials, log paths, and other settings.
-
Set the configuration
smart-logger set_config -
Verify active configuration
smart-logger show_config→ Ensures everything is correctly set.
-
Initialize database tables
smart-logger init-db -
Create an admin user
smart-logger create-admin-user -
Run the Smart Logger Dashboard UI
smart-logger ui --host 127.0.0.1 --port 8000
✅ Now your logging system with UI is ready!
Usage
1. FastAPI Example
from fastapi import FastAPI
from smart_logger import SmartLogger
app = FastAPI()
logger = SmartLogger()
@app.get("/")
def home():
logger.info("Home accessed") # UUID, folder, filename auto-detected
return {"message": "Hello FastAPI"}
2. Flask Example
from flask import Flask
from smart_logger import SmartLogger
app = Flask(__name__)
logger = SmartLogger()
@app.route("/")
def home():
logger.info("Home accessed")
return "Hello Flask"
3. Django Example
from smart_logger import SmartLogger
logger = SmartLogger()
def example_view(request):
logger.info("Django view accessed")
from django.http import HttpResponse
return HttpResponse("Hello Django")
CLI Commands
Launch Dashboard UI
smart-logger ui --host 127.0.0.1 --port 8000 --workers 1 --reload False
--reloadoptional (defaultFalse)- Runs isolated FastAPI server independent of main project
Initialize Database Tables
smart-logger init-db
Admin User Management
- Create admin user:
smart-logger create-admin-user
- Change password:
smart-logger change-password <email>
- Forgot password (reset without old password):
smart-logger forgot-password <email>
- List users:
smart-logger list-users
- Delete user:
smart-logger delete-user <email>
Configuration Management
- Set global config:
smart-logger set_config
- Show active config:
smart-logger show_config
- Create default config:
smart-logger make-smart-logger-default-conf
Folder Structure
smart_logger/
├── cli/
├── config/
├── core/
├── exceptions/
├── models/
├── security/
├── ui/
├── tests/
├── examples/
├── setup.py
├── pyproject.toml
├── setup.cfg
├── LICENSE
└── README.md
core/→ Logger class, DB handlersui/→ Dashboard server, templates, static filescli/→ Commands for server launch, user managementmodels/→ SQLAlchemy modelssecurity/→ Auth, middleware, blacklist tokenconfig/→ Default and global configurationtests/→ Unit and integration testsexamples/→ Usage examples
Logging API
from smart_logger import SmartLogger
logger = SmartLogger()
logger.info("Informational message")
logger.warning("Warning message")
logger.error("Error message")
logger.critical("Critical message")
logger.debug("Debugging message")
- Folder and file auto-detection: module name used if not provided
- UUID generated for every log entry
- Database metadata stored automatically
Dashboard Features
-
Real-time log view
-
Filter by: date, time, UUID, log type
-
Charts:
- Daily/Monthly/Yearly error insights
- Bar charts by log type
-
System info: CPU, memory, uptime
-
Cards & Stats for quick overview
-
Logout button for secure access
License
MIT License. See LICENSE file for details.
✅ Key Points:
- Step-by-step setup guide added.
- Clear instructions for installation and usage.
- Examples for FastAPI, Flask, Django included.
- CLI instructions for UI and DB initialization.
- Folder structure overview for developers.
- Ready for PyPI and GitHub documentation.
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
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 az_smart_logger-1.0.3.tar.gz.
File metadata
- Download URL: az_smart_logger-1.0.3.tar.gz
- Upload date:
- Size: 33.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab3219c4ce698c7f1ad338c09c2a63769cfd61e348004ee76f3d27f08110f13f
|
|
| MD5 |
4ad50f3252321137ed39d83060d88767
|
|
| BLAKE2b-256 |
2bb8bac110a7e23e5a61fa2df562b761815eae7cbbe1b3a5570e12d720e690bb
|
File details
Details for the file az_smart_logger-1.0.3-py3-none-any.whl.
File metadata
- Download URL: az_smart_logger-1.0.3-py3-none-any.whl
- Upload date:
- Size: 47.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3ec7327895de8d55f18faac267f0feaffd89accdfe8f006da7e6d7636eac613
|
|
| MD5 |
3692b7bc399a57cb7ba1fbdbf2836d6a
|
|
| BLAKE2b-256 |
f0438b59b18971ee0442eccba107b28d2a20e34383864d8603127464dbabc97c
|