InsightLogger
is an advanced, customizable logging library designed for Python applications. It enables performance monitoring, detailed error logging, visual log representation, and execution summaries to gain better insights.
- Flexible Logging: Supports multiple log levels (INFO, DEBUG, ERROR, etc.) with customizable formats and handles both console and file logs.
- Rotating Logs: Automatically manages log file sizes and prevents excessive disk usage through rotating log files.
- Execution Time Tracking: Use decorators to measure and log the execution time of functions, including a live spinning animation during function execution.
- Log Visualization: Automatically generates bar charts that display the frequency of different log levels.
- Environmental Insights: Captures and displays detailed runtime environment information, including system specs and resource usage.
- Advanced Log Formatting: Adds visual styles like bold, underline, and headers to log messages for better clarity.
-
Clone the repository:
git clone https://github.com/VelisCore/InsightLogger.git
-
Install the required dependencies:
pip install -r requirements.txt
Dependencies include:
termcolor
for colored console output.matplotlib
for visualizing logs.tabulate
for neatly formatted tables.psutil
for monitoring system resources.
from insightlog import InsightLogger
# Initialize the logger
logger = InsightLogger(name="AppLog")
@logger.log_function_time
def example_function():
time.sleep(2)
# Logging
logger.log("INFO", "This is an info log.")
logger.log("ERROR", "An error occurred.")
# Visualize logs and generate a summary
logger.generate_log_visualization()
summary = logger.generate_execution_summary()
logger.logger.info("\nLog Summary:\n" + summary)
You can log messages with various severity levels such as INFO, ERROR, SUCCESS, WARNING, etc.
logger.log("INFO", "This is an info message.")
logger.log("ERROR", "An error occurred.")
Use the @log_function_time
decorator to measure and log the execution time of functions.
@logger.log_function_time
def sample_function():
time.sleep(1.5)
Supported log levels include:
- INFO
- ERROR
- SUCCESS
- FAILURE
- WARNING
- DEBUG
- ALERT
- TRACE
- CRITICAL
Each log level has its own format for console output.
After logging, InsightLogger provides valuable insights including:
- Environmental Info: Python version, OS version, machine specs (CPU, memory, etc.), and uptime.
- Log Level Distribution: A bar chart showing the frequency of each log level.
logger.generate_environment_summary() # Displays environment details
logger.generate_log_visualization() # Generates and saves the log distribution chart
Console Output:
[INFO] This is an info log.
[ERROR] An error occurred.
Function 'example_function' executed in 1500.12 ms.
Environment Summary:
Environment Info | Details |
---|---|
Python Version | 3.10 |
OS | Windows |
RAM | 16.00 GB |
Total Errors | 1 |
Log Frequency Chart: (Bar chart displaying the frequency of different log levels)
- Rotating Logs: Configure log rotation to prevent excessive disk usage.
- Real-Time Execution Tracker: Display the real-time execution time of functions with a live spinning animation.
- Error and Execution Tracking: Track error counts, execution times, and resource usage (CPU, memory).
Contributions to InsightLogger are welcome. To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with detailed descriptions of the changes.
InsightLogger is licensed under the MIT License. See LICENSE for details.
For issues or feature requests, please open an issue.
Developed by VelisCore.
- InsightLogger automatically creates a folder named
.insight
to store logs and visualizations. - The logging system supports both console output and file logs, with rotation based on size.