Lightweight, file-backed logger with colored console output
Project description
# EchoLog 🪶
A lightweight and colorful Python logger for daily logging — built for simplicity, readability, and reliability.
EchoLog logs messages both to the console (with colors using **colorama**) and to a daily log file automatically created under a configurable `logs/` folder.
---
## ✨ Features
- **Daily log files** — automatically organized by date
- **Colorized console output** (via `colorama`)
- **Simple API** — `info()`, `error()`, `debug()`, etc.
- **Custom log levels** including `SMTP` and `AUDIT`
- **Custom formatting** support via user-defined callback
- **Optional environment variable** for log folder (`ECHOLOG_LOGS_FOLDER`)
- **Graceful fallback** if file writing fails
---
## 📦 Installation
```bash
pip install colorama
coloramais optional — if unavailable, EchoLog still works for file-only logging.
🧠 Quick Start
from echolog import Logger, LogLevel
logger = Logger("MyApp")
logger.info("Application started successfully.")
logger.debug("Debugging details here...")
logger.warning("This might cause issues later.")
logger.error("Something went wrong!")
logger.critical("Critical failure encountered.")
logger.smtp("SMTP message logged.")
logger.audit("User access event recorded.")
Console Output:
2025-10-06 [INFO] [MyApp] Application started successfully.
2025-10-06 [ERROR] [MyApp] Something went wrong!
File Output (logs/2025-10-06.log):
[2025-10-06 14:33:02] [INFO] [MyApp] Application started successfully.
[2025-10-06 14:33:05] [ERROR] [MyApp] Something went wrong!
🗂️ Log Files
By default, EchoLog stores logs in the logs/ directory, one file per day:
logs/
├─ 2025-10-06.log
├─ 2025-10-07.log
└─ ...
To change this location, set an environment variable:
export ECHOLOG_LOGS_FOLDER=/var/log/myapp
🧩 Custom Formatting
You can define your own console format function:
def custom_format(msg, level):
return f"[{level.text}] :: {msg.upper()}"
logger.set_custom_format(custom_format)
logger.info("custom formatting enabled")
🧾 API Reference
Logger(name: Optional[str] = None)
Creates a new logger instance.
If name is provided, it’s included in all log entries.
Methods
| Method | Description |
|---|---|
debug(text, print_only=False) |
Log a debug message. |
info(text) |
Log an info message. |
notice(text) |
Log an informational notice. |
warning(text) |
Log a warning. |
error(text) |
Log an error message. |
critical(text) |
Log a critical error. |
smtp(text) |
Log SMTP-related events. |
audit(text) |
Log security or access events. |
get_logs() |
Return the current day’s log lines as a list. |
file_name() |
Return the current log file’s full path. |
set_custom_format(formatter) |
Set a function that customizes console output. |
🧱 Log Levels
| Level | Color | Example Prefix |
|---|---|---|
DEBUG |
Cyan | [DEBUG] |
INFO |
Green | [INFO] |
NOTICE |
Blue | [NOTICE] |
WARNING |
Yellow | [WARNING] |
ERROR |
Red | [ERROR] |
CRITICAL |
Magenta | [CRITICAL] |
SMTP |
Light Cyan | [SMTP SERVER] |
AUDIT |
Light Blue | [AUDIT] |
⚙️ Internals
Each log line follows this structure:
[YYYY-MM-DD HH:MM:SS] [LEVEL] [LoggerName] message
- Files are appended daily
- If the
logsfolder cannot be created, EchoLog falls back to the current directory - Handles file I/O errors gracefully and continues printing to console
🧩 Example Project Layout
my_project/
├─ echolog/
│ ├─ __init__.py
│ ├─ logger.py
├─ main.py
└─ logs/
main.py:
from echolog import Logger
log = Logger("Main")
log.info("App initialized.")
🧰 Environment Variables
| Variable | Description | Default |
|---|---|---|
ECHOLOG_LOGS_FOLDER |
Directory for log files | "logs" |
🪶 License
Copyright © 2025 Aymene Boudali All rights reserved.
You may use and distribute EchoLog as part of your personal or commercial projects without modification. You may not edit, alter, or redistribute modified versions of this library under any name.
Usage in compiled, packaged, or public software is permitted — provided EchoLog remains intact and unmodified.
⚠️ Legal Notes
- Modification of the code or derived works is strictly prohibited.
- Redistribution must include this README and full copyright notice.
- Use is allowed in both open-source and closed-source projects if unchanged.
- Credit to Aymene Boudali is required in any documentation or about section.
🤝 Acknowledgments
Special thanks to developers and open-source contributors who inspired EchoLog’s simplicity. Built with ❤️ in Python.
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 pyecholog-3.0.5.tar.gz.
File metadata
- Download URL: pyecholog-3.0.5.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27c9236ce6b61401f416116f8fb7974a05b27898d96fde645a0e1e567589bd91
|
|
| MD5 |
43bdf74c1c78575facdaf4b05d5146fb
|
|
| BLAKE2b-256 |
4a2118a3365da9eb198eb775fc3dff70629336690544e5e941cf9885d1e55177
|
File details
Details for the file pyecholog-3.0.5-py3-none-any.whl.
File metadata
- Download URL: pyecholog-3.0.5-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adfaf9a56619bf228a7c49d950babc11223714b31d284b305e5bc2a0e5624f66
|
|
| MD5 |
a5c172a211470ccd68c68aff14b66c23
|
|
| BLAKE2b-256 |
a3c3a6d7cd748d42dcd83683fa749cbfdf55f8b3763ceefcfffe20b16c9ab934
|