Some checks failed
- Added @click.version_option decorator to main() in commands.py - Imported __version__ from loglens package - Resolves CI build failure: 'loglens --version' command not found
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from typing import Any
|
|
|
|
from loglens.analyzers.analyzer import AnalysisResult
|
|
|
|
|
|
class TextFormatter:
|
|
"""Format analysis results as plain text."""
|
|
|
|
def format(self, result: Any) -> str:
|
|
"""Format result as text."""
|
|
if not hasattr(result, "to_dict"):
|
|
return str(result)
|
|
|
|
data = result.to_dict()
|
|
lines = []
|
|
lines.append("=" * 60)
|
|
lines.append("LOG ANALYSIS")
|
|
lines.append("=" * 60)
|
|
lines.append(f"Total Lines: {data['total_lines']}")
|
|
lines.append(f"Format: {data['format_detected']}")
|
|
lines.append("")
|
|
lines.append("Severity Counts:")
|
|
lines.append(f" Critical: {data['critical_count']}")
|
|
lines.append(f" Error: {data['error_count']}")
|
|
lines.append(f" Warning: {data['warning_count']}")
|
|
lines.append(f" Debug: {data['debug_count']}")
|
|
|
|
if data.get("suggestions"):
|
|
lines.append("")
|
|
lines.append("Suggestions:")
|
|
for suggestion in data["suggestions"]:
|
|
lines.append(f" - {suggestion}")
|
|
|
|
return "\n".join(lines)
|