init method

  1. @override
Future<void>? init(
  1. Map<String, dynamic> config,
  2. bool test,
  3. DateTime? date
)
override

Setup the appender. This needs to be called for every appender to configure the appender with the necessary data.

Implementation

@override
Future<void>? init(Map<String, dynamic> config, bool test, DateTime? date) {
  created = date ?? DateTime.now();
  type = AppenderType.HTTP;
  if (config.containsKey('level')) {
    level = Level.fromString(config['level']);
  } else {
    level = Level.INFO;
  }
  if (config.containsKey('dateFormat')) {
    dateFormat = config['dateFormat'];
  } else {
    dateFormat = Appender.defaultDateFormat;
  }
  if (config.containsKey('url')) {
    url = config['url'];
  } else {
    throw ArgumentError('Missing url argument for HttpAppender');
  }
  headers = {};
  if (config.containsKey('headers')) {
    List<String> h = config['headers'];
    for (var s in h) {
      var splitted = s.split(':');
      headers!
          .putIfAbsent(splitted.elementAt(0), () => splitted.elementAt(1));
    }
  }
  return null;
}