Chronolog is an intelligent logging, profiling, and diagnostics system for Python projects.
It automatically tracks all modules, functions, and classes, measures execution time,
archives old logs, and generates detailed reports with avg / min / max / total metrics.
Chronolog combines time (chrono) and logging (log) —
creating a tool that doesn’t just write logs, but tells the story of your code’s execution over time.
- 🔁 Automatic logging of all functions and methods
- ⏱️ Execution time measurement with microsecond precision
- 📊 Performance analytics — average, minimum, and maximum timings
- 📦 Automatic archiving of logs from each session (ZIP)
- 🧩 Support for nested modules and classes
- 🧠 Diagnostics and detailed reports for modules, functions, and classes
- 🕸 Call Graphs based on
trace_id - 🗑️ Automatic cleanup of old archives
- 💡 Built on top of Loguru — a fast and powerful logging engine
logs/
│
├── app_info.log # INFO level logs
├── app_error.log # Errors and exceptions
└── archives/ # Archived logs (.zip)
Before each new session, Chronolog automatically archives previous logs,
keeping a clean and organized history of your program’s runs.
import my_project_module
from chronolog import (
setup_logger_for_module,
print_all_stats,
print_wrapped_info,
get_global_logger
)
logger = get_global_logger()
# Wrap the module to automatically track all functions and classes
setup_logger_for_module(my_project_module)
# Run your main logic
my_project_module.main()
# After execution — print collected statistics
print_all_stats()
print_wrapped_info()import time
def fetch_data():
time.sleep(0.3)
def process_data():
time.sleep(0.4)
class Analyzer:
def run(self):
time.sleep(0.2)
self.subtask()
def subtask(self):
time.sleep(0.1)
def main():
fetch_data()
process_data()
a = Analyzer()
a.run()✅ Previous logs archived to: logs/archives/logs_2025-10-27_21-03-00.zip
INFO | my_project_module.fetch_data executed in 0.3019 sec
INFO | my_project_module.process_data executed in 0.4015 sec
INFO | my_project_module.Analyzer.run executed in 0.3016 sec
INFO | my_project_module.Analyzer.subtask executed in 0.1011 sec
=== FINAL EXECUTION STATS ===
📊 Total wrapped functions: 5
📊 Total wrapped classes: 1
📊 Total tracked calls: 4
=== Module Execution Summary ===
📦 my_project_module: 4 calls | total 1.1059 sec | avg 0.2765 sec | min 0.1011 sec | max 0.4015 sec
=== Function Execution Summary ===
🔹 my_project_module.process_data: 1 calls | total 0.4015 sec
🔹 my_project_module.Analyzer.run: 1 calls | total 0.3016 sec
🔹 my_project_module.fetch_data: 1 calls | total 0.3019 sec
🔹 my_project_module.Analyzer.subtask: 1 calls | total 0.1011 secprint_wrapped_info() # shows all wrapped functions and classes
print_all_stats() # prints performance and timing statisticsFunction Description
setup_logger_for_module(module_or_class) #Automatically wraps all functions and methods
print_all_stats() #Prints aggregated execution statistics
print_wrapped_info() #Displays wrapped functions and classes
cleanup_old_archives(keep_last=10) #Deletes old log archives
get_global_logger() #Returns the active loguru.logger instancepip install -r requirements.txtOr simply add chronolog.py to your project and import it:
from chronolog import setup_logger_for_moduleMIT License © 2025 Author: ChronoLab / Mekhty
Ideas and suggestions are welcome! Open an Issue or Pull Request on GitHub and help make Chronolog even smarter 🧠.