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);
Level | Use Case | Output |
---|---|---|
Level.FINE | Development | Verbose |
Level.INFO | General | Moderate |
Level.WARNING | Production | Minimal |
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');
Next Steps
- Automatic Retry - Handle rate limits
- Usage Tracking - Monitor costs