Logging

Route and filter debug output from the agent.

Basic Usage

// Enable default logging
Agent.loggingOptions = const LoggingOptions();

final agent = Agent('openai');
await agent.send('Hello!');
// See formatted logs in console

Logging Levels

import 'package:logging/logging.dart';

// Development - verbose output
Agent.loggingOptions = LoggingOptions(level: Level.FINE);

// Production - minimal output  
Agent.loggingOptions = LoggingOptions(level: Level.WARNING);
LevelUse CaseOutput
Level.FINEDevelopmentVerbose
Level.INFOGeneralModerate
Level.WARNINGProductionMinimal

Filter by Provider

// Only OpenAI logs
Agent.loggingOptions = LoggingOptions(
  filter: 'openai',
  onRecord: (record) => print('OpenAI: ${record.message}'),
);

// Only HTTP retry logs
Agent.loggingOptions = LoggingOptions(filter: 'http');

Examples

Next Steps