LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
ai::LogAnalyzer Class Reference

Analyzes logs using AI to provide insights. More...

#include <LogAnalyzer.hpp>

Collaboration diagram for ai::LogAnalyzer:
Collaboration graph

Public Types

enum class  AnalysisType {
  Summary , ErrorAnalysis , PatternDetection , RootCause ,
  Timeline
}
 

Public Member Functions

 LogAnalyzer (std::shared_ptr< AIServiceWrapper > aiService)
 
std::string Analyze (AnalysisType type, size_t maxEvents=100, const std::vector< unsigned long > *filteredIndices=nullptr)
 Perform analysis on current log data.
 
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.
 
bool IsReady () const
 Check if AI service is ready.
 

Static Public Member Functions

static std::string GetAnalysisTypeName (AnalysisType type)
 Get human-readable name for analysis type.
 

Private Member Functions

std::string FormatEventsForAI (size_t maxEvents, const std::vector< unsigned long > *filteredIndices) const
 
void FormatSingleEvent (std::ostringstream &oss, size_t index, const nlohmann::json &eventJson) const
 
std::string BuildPrompt (AnalysisType type, const std::string &logData) const
 

Private Attributes

std::shared_ptr< AIServiceWrapper > m_aiService
 

Detailed Description

Analyzes logs using AI to provide insights.

Member Enumeration Documentation

◆ AnalysisType

enum class ai::LogAnalyzer::AnalysisType
strong
Enumerator
Summary 
ErrorAnalysis 
PatternDetection 
RootCause 
Timeline 

Constructor & Destructor Documentation

◆ LogAnalyzer()

ai::LogAnalyzer::LogAnalyzer ( std::shared_ptr< AIServiceWrapper >  aiService)
explicit

Member Function Documentation

◆ Analyze()

std::string ai::LogAnalyzer::Analyze ( AnalysisType  type,
size_t  maxEvents = 100,
const std::vector< unsigned long > *  filteredIndices = nullptr 
)

Perform analysis on current log data.

Parameters
typeType of analysis to perform
maxEventsMaximum number of events to include (0 = all)
filteredIndicesOptional: specific event indices to analyze (respects user filters)
Returns
Analysis results as text
Here is the call graph for this function:

◆ AnalyzeWithCustomPrompt()

std::string ai::LogAnalyzer::AnalyzeWithCustomPrompt ( const std::string &  customPrompt,
size_t  maxEvents = 100,
const std::vector< unsigned long > *  filteredIndices = nullptr 
)

Perform analysis with custom user-defined prompt.

Parameters
customPromptUser-provided analysis prompt
maxEventsMaximum number of events to include (0 = all)
filteredIndicesOptional: specific event indices to analyze (respects user filters)
Returns
Analysis results as text
Here is the call graph for this function:

◆ BuildPrompt()

std::string ai::LogAnalyzer::BuildPrompt ( AnalysisType  type,
const std::string &  logData 
) const
private
Here is the caller graph for this function:

◆ FormatEventsForAI()

std::string ai::LogAnalyzer::FormatEventsForAI ( size_t  maxEvents,
const std::vector< unsigned long > *  filteredIndices 
) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FormatSingleEvent()

void ai::LogAnalyzer::FormatSingleEvent ( std::ostringstream &  oss,
size_t  index,
const nlohmann::json &  eventJson 
) const
private
Here is the caller graph for this function:

◆ GetAnalysisTypeName()

std::string ai::LogAnalyzer::GetAnalysisTypeName ( AnalysisType  type)
static

Get human-readable name for analysis type.

Here is the caller graph for this function:

◆ IsReady()

bool ai::LogAnalyzer::IsReady ( ) const

Check if AI service is ready.

Member Data Documentation

◆ m_aiService

std::shared_ptr<AIServiceWrapper> ai::LogAnalyzer::m_aiService
private

The documentation for this class was generated from the following files: