loadFromConfig method

  1. @override
void loadFromConfig(
  1. ConfigInterface config, {
  2. String channel = "app",
})
override

Loads logger configuration from the application config system.

This method reads logging configuration from the provided config and sets up the appropriate handlers for each channel.

config - The application configuration interface channel - The default channel name (optional)

Implementation

@override
void loadFromConfig(ConfigInterface config, {String channel = "app"}) {
  final loggingConfig = LoggingConfiguration(config);

  // Validate configuration
  loggingConfig.validate();

  // Apply configuration
  _minimumLevel = loggingConfig.minimumLevel;
  _defaultChannel = loggingConfig.defaultChannel;

  // Clear existing handlers and add new ones
  _channelManager.clearAll();

  final channels = loggingConfig.channels;
  for (final entry in channels.entries) {
    final channelName = entry.key;
    final handlers = entry.value;

    for (final handler in handlers) {
      _channelManager.addHandler(handler, channel: channelName);
    }
  }
}