LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
LogAnalyzer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IAIService.hpp"
5#include "PluginEventsC.h"
6#include <nlohmann/json.hpp>
7#include <string>
8#include <memory>
9#include <vector>
10
11namespace ai
12{
13
18{
19public:
20 enum class AnalysisType
21 {
22 Summary, // Generate executive summary
23 ErrorAnalysis, // Focus on errors and their causes
24 PatternDetection, // Find unusual patterns
25 RootCause, // Identify root cause of issues
26 Timeline // Create timeline narrative
27 };
28
29 explicit LogAnalyzer(std::shared_ptr<AIServiceWrapper> aiService);
30
38 std::string Analyze(AnalysisType type, size_t maxEvents = 100,
39 const std::vector<unsigned long>* filteredIndices = nullptr);
40
48 std::string AnalyzeWithCustomPrompt(const std::string& customPrompt, size_t maxEvents = 100,
49 const std::vector<unsigned long>* filteredIndices = nullptr);
50
54 bool IsReady() const;
55
59 static std::string GetAnalysisTypeName(AnalysisType type);
60
61private:
62 std::shared_ptr<AIServiceWrapper> m_aiService;
63
64 std::string FormatEventsForAI(size_t maxEvents, const std::vector<unsigned long>* filteredIndices) const;
65 void FormatSingleEvent(std::ostringstream& oss, size_t index, const nlohmann::json& eventJson) const;
66 std::string BuildPrompt(AnalysisType type, const std::string& logData) const;
67};
68
69} // namespace ai
Analyzes logs using AI to provide insights.
Definition LogAnalyzer.hpp:18
std::string BuildPrompt(AnalysisType type, const std::string &logData) const
Definition LogAnalyzer.cpp:315
void FormatSingleEvent(std::ostringstream &oss, size_t index, const nlohmann::json &eventJson) const
Definition LogAnalyzer.cpp:293
bool IsReady() const
Check if AI service is ready.
Definition LogAnalyzer.cpp:174
std::shared_ptr< AIServiceWrapper > m_aiService
Definition LogAnalyzer.hpp:62
std::string FormatEventsForAI(size_t maxEvents, const std::vector< unsigned long > *filteredIndices) const
Definition LogAnalyzer.cpp:192
AnalysisType
Definition LogAnalyzer.hpp:21
static std::string GetAnalysisTypeName(AnalysisType type)
Get human-readable name for analysis type.
Definition LogAnalyzer.cpp:179
std::string Analyze(AnalysisType type, size_t maxEvents=100, const std::vector< unsigned long > *filteredIndices=nullptr)
Perform analysis on current log data.
Definition LogAnalyzer.cpp:20
std::string AnalyzeWithCustomPrompt(const std::string &customPrompt, size_t maxEvents=100, const std::vector< unsigned long > *filteredIndices=nullptr)
Perform analysis with custom user-defined prompt.
Definition LogAnalyzer.cpp:91
Definition GemmaInferenceEngine.cpp:18