config method

void config(
  1. ConfigResponse config
)

Implementation

void config(ConfigResponse config) {
  clear();
  for (final appender in config.appenders) {
    try {
      final config = appender.config ?? {};
      final base = BaseAppender.create(appender.type, appender.name, config);
      appenders[appender.name] = base;
    } catch (e) {
      InnerLog().e('Error creating appender: $appender.name');
    }
  }

  for (final logger in config.loggers) {
    final appender = appenders[logger.appenderRef];
    if (appender != null) {
      final log = Logger(
        logger.name ?? '',
        stringToSeverity(logger.severity),
        stringToSeverity(logger.callStackSeverity ?? 'Off'),
        appender
      );
      loggers.add(log);
    }
  }

  EventEmitter().emit(EventType.configChange, config);
}