getConfiguration method
Gets the configuration for the specified logger provider type.
The providerType parameter should be the Type of the logger provider
(e.g., ConsoleLoggerProvider, DebugLoggerProvider).
The factory will search for configuration sections matching either:
- The full type name of the provider
- The provider's alias (if defined via ProviderAlias attribute)
Returns an IConfiguration containing the merged configuration from all matching sections.
Implementation
@override
IConfiguration getConfiguration(Type providerType) {
ArgumentError.checkNotNull(providerType, 'providerType');
// Get the provider's alias (e.g., "Console" from "ConsoleLoggerProvider")
final alias = ProviderAliasUtilities.getAlias(providerType);
// Get the full type name
final fullName = ProviderAliasUtilities.getFullName(providerType);
// Build a composite configuration from all matching sections
final builder = ConfigurationBuilder();
for (final logConfig in _configurations) {
final config = logConfig.configuration;
// Try to get configuration section using the alias first
// (e.g., "Console")
if (alias != null) {
final aliasSection = config.getSection('Logging:$alias');
if (_hasChildren(aliasSection)) {
_addConfiguration(builder, aliasSection);
}
}
// Also try the full type name (e.g., "ConsoleLoggerProvider")
final fullNameSection = config.getSection('Logging:$fullName');
if (_hasChildren(fullNameSection)) {
_addConfiguration(builder, fullNameSection);
}
}
return builder.build();
}