shebang-after-blankβ’1.28 kB
#!/usr/bin/env python3
# Test fixture: Python script with blank line before shebang
# This file has no extension and should be auto-detected as code
import sys
import os
from datetime import datetime
class LogAnalyzer:
"""Simple log file analyzer."""
def __init__(self, log_path):
self.log_path = log_path
self.errors = []
self.warnings = []
def parse_log(self):
"""Parse log file and categorize entries."""
try:
with open(self.log_path, 'r') as f:
for line in f:
if 'ERROR' in line:
self.errors.append(line.strip())
elif 'WARN' in line:
self.warnings.append(line.strip())
except FileNotFoundError:
print(f"Error: Log file {self.log_path} not found")
sys.exit(1)
def print_summary(self):
"""Print summary of log analysis."""
print(f"\n=== Log Analysis Summary ===")
print(f"Errors: {len(self.errors)}")
print(f"Warnings: {len(self.warnings)}")
print(f"Analyzed at: {datetime.now()}")
if __name__ == '__main__':
analyzer = LogAnalyzer('/var/log/app.log')
analyzer.parse_log()
analyzer.print_summary()