init method
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;
}