https://github.com/sgudkov/homework-20250127
https://github.com/sgudkov/homework-20250127
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sgudkov/homework-20250127
- Owner: Sgudkov
- Created: 2025-02-11T11:27:14.000Z (4 months ago)
- Default Branch: origin
- Last Pushed: 2025-02-13T21:05:40.000Z (4 months ago)
- Last Synced: 2025-02-13T21:24:58.386Z (4 months ago)
- Language: Python
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Log Analyzer
================The Log Analyzer is a Python script designed to process log files and generate reports in HTML format. The script reads log files, parses the data, and produces a report that provides insights into URL access patterns.
## Functionality
The Log Analyzer performs the following functions:
- Reads log files in gzip format
- Parses log data and extracts relevant information
- Generates reports in HTML format
- Produces reports that include URL access patterns, such as count, percentage, time sum, time percentage, time average, time maximum, and time median
- Limits reports to the first `REPORT_SIZE` lines
- Sorts reports by time percentage in descending order## Configuration
The Log Analyzer uses a configuration file (`conf.json`) to set report size, report directory, and log directory.
### Configuration Options
- `REPORT_SIZE`: The maximum number of lines to include in the report.
- `REPORT_DIR`: The directory where the report will be saved.
- `LOG_DIR`: The directory where the log files are located.### Example Configuration File (`conf.json`)
```json
{
"REPORT_SIZE": 2000,
"REPORT_DIR": "./reports",
"LOG_DIR": "./log"
}
```## Report
The report is generated in HTML format and includes the following information:
- URL access patterns, including count, percentage, time sum, time percentage, time average, time maximum, and time median
- The report is sorted by time percentage in descending order
- The report is limited to the first `REPORT_SIZE` lines## Usage
To use the Log Analyzer, simply execute the `log_analyzer.py` script and provide the path to your log file as a command-line argument.
Example usage:
```bash
python log_analyzer.py -c ./conf.json