AILogStrategy class

AI Log Strategy for Strategic Logger

This strategy integrates with AI models and services to provide:

  • Intelligent log analysis
  • Pattern detection
  • Anomaly detection
  • Automated insights and recommendations
  • Natural language log summaries
Inheritance

Constructors

AILogStrategy.new({required String apiKey, String baseUrl = 'https://api.openai.com/v1', bool enableAnalysis = true, bool enableInsights = true, bool enableAnomalyDetection = true, Duration analysisInterval = const Duration(minutes: 5), int batchSize = 100})

Properties

analysisTimer Timer?
Analysis timer for testing
no setter
hashCode int
The hash code for this object.
no setterinherited
insightsStream Stream<AIInsight>
Stream of AI insights
no setter
logBuffer List<AILogEntry>
Log buffer for testing
no setter
loggerLogLevel LogLevel
The log level set by the logger using this strategy. Used to determine if a message should be logged.
getter/setter pairinherited
logLevel LogLevel
The minimum log level that this strategy handles for logging.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedEvents List<LogEvent>?
A list of specific LogEvent types that this strategy supports. If null, all events are considered supported.
getter/setter pairinherited

Methods

buildAnalysisPrompt(List<AILogEntry> entries) String
Build analysis prompt for testing
buildContext(Map<String, dynamic>? additionalContext, StackTrace? stackTrace) Map<String, dynamic>
Build context for testing
buildSystemPrompt() String
Build system prompt for testing
determineInsightType(AIAnalysisResult result) AIInsightType
Determine insight type for testing
dispose() → void
error({dynamic error, StackTrace? stackTrace, LogEvent? event}) Future<void>
Abstract method to log an error.
override
extractRecommendations(String content) List<String>
Extract recommendations for testing
fatal({dynamic error, StackTrace? stackTrace, LogEvent? event}) Future<void>
Abstract method to log a fatal error.
override
formatMessage(dynamic message) String
Format message for testing
generateLogId() String
Generate log ID for testing
generateLogSummary({Duration? timeRange, int? maxLogs}) Future<String>
Generates a summary of recent logs
info({dynamic message, LogEvent? event}) Future<void>
Abstract method to info a message or event (same as log()).
override
log({dynamic message, LogEvent? event}) Future<void>
Abstract method to log a message or event.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldLog({LogEvent? event}) bool
Determines whether a log operation should proceed based on the event and log level.
inherited
startAnalysis() → void
Starts the AI analysis timer
stopAnalysis() → void
Stops the AI analysis timer
toString() String
Provides a string representation of the strategy including its type and log level.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited