MCPLogStrategy class
MCP Log Strategy for Strategic Logger
This strategy integrates with the Model Context Protocol (MCP) server to provide AI agents with structured logging capabilities.
Features:
- Structured logging for AI consumption
- Real-time log streaming
- Query capabilities for log analysis
- Health monitoring through logs
- Inheritance
-
- Object
- LogStrategy
- MCPLogStrategy
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
- mcpServer → MCPServer
-
MCP Server instance for testing
no setter
- 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
-
buildContext(
Map< String, dynamic> ? additionalContext, StackTrace? stackTrace) → Map<String, dynamic> - Build context for testing
-
dispose(
) → void -
error(
{dynamic error, StackTrace? stackTrace, LogEvent? event}) → Future< void> -
Abstract method to log an error.
override
-
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
-
getHealthStatus(
) → Future< Map< String, dynamic> > - Gets health status from the MCP server
-
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
-
queryLogs(
{LogLevel? level, DateTime? since, DateTime? until, String? message, Map< String, String> ? context, String? sortBy, int? limit}) → Future<List< MCPLogEntry> > - Queries logs from the MCP server
-
shouldLog(
{LogEvent? event}) → bool -
Determines whether a log operation should proceed based on the event and log level.
inherited
-
startServer(
) → Future< void> - Starts the MCP server if not already running
-
stopServer(
) → Future< void> - Stops the MCP server
-
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