Table of Contents
Overview
This project is a custom logging module built from scratch in Python using object-oriented programming (OOP).
It provides a structured, extensible, and lightweight way to capture, format, and store log messages across multiple output formats (console, file, and database).
Features
Key highlights of ESTROSEC’s Python Logger:
- Multi-Type Logging — TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, FATAL
- Multi-Level Logging — ALL, HIGH, MEDIUM, LOW
- Multi-Output Logging — Console, File, SQLite Database
- Named Loggers — Create multiple loggers with custom names/categories
-
Configurable File Logging — Choose custom file paths for
.log
files - Toggleable Outputs — Enable/disable console, file, or DB logging dynamically
- Seamless OOP Integration — Designed for easy integration into OOP-based projects
- Lightweight & Reusable — Plug-and-play across Python projects
Showcase
Console Logging
- Clean, modern formatting with colored output
- Format: [LoggerName] [Timestamp] [Level] Message
File Logging
- Same format as console logging (no colors)
- Stored in
.log
files for persistence
Database Logging (SQLite3)
- Logs stored in a structured SQLite database
- Data separated into columns for easy querying & analysis
- Current limitation: DB file stored in a fixed location (configurable in future roadmap)
Getting Started
1. Download the Code
Download the latest release to get the logger.py
module.
2. Add to Your Project
Place the logger.py
file in your project directory:
Your-Project/
├─ main.py
└─ logger.py
3. Import the Logger
from logger import Logger, LogLevel
Usage
Create a Logger
log = Logger("MyLogger")
Console Logging
log.fatal("Fatal error occurred: %s", "Disk not found")
log.error("Error: %d", 404)
log.warning("Low memory: %f GB left", 1.25)
log.success("Operation completed successfully")
log.information("Service started")
log.debug("Debugging variable x=%d", 42)
log.trace("Tracing execution flow")
Enable File Logging
log.set_toggle_file_logging(True)
Enable Database Logging
log.set_toggle_db_logging(True)
Set File Path for Logs
log.set_file_path("C:\\Users\\YourName\\logs")
Control Log Levels
Available options:
- ALL — Logs all message types
- HIGH — Logs FATAL, ERROR, WARNING, SUCCESS
- MEDIUM — Logs FATAL, ERROR, WARNING
- LOW — Logs FATAL, ERROR
log.set_log_level(LogLevel.LOW)
Tech Stack
- Language: Python 3
-
Modules:
inspect
,os
,enum
,datetime
,sqlite3
- Tools: PyCharm, DataGrip, GitHub, Git
Roadmap
- SQLite Logging
- MySQL Logging
- Multi-threaded Logging
- Async Logging
- Custom Log Message Types
Resources
- GitHub Repositories: ESTROSEC
- GitHub Project Repository: ESTROSEC
- Medium: ESTROSEC
- Dev.To: ESTROSEC
- Patreon: ESTROSEC
- Tumblr: ESTROSEC
Stay updated with new projects, tutorials, and announcements!
Want to get the latest news and updates when they come out?
We will email you with any relevant information as soon as we have it!
Send us an email with the subject line "I LOVE ESTROSEC!"
and a body of "NEWS & UPDATES YAY!"
Top comments (0)