Logger constructor
Implementation
Logger({
List<Filter>? filters,
required List<Output> outputs,
}) : _outputs = outputs {
if (filters != null && filters.length > 0) {
filters.forEach((filter) {
_streamController.stream
.where(filter.where)
.transform(filter.streamTransformer)
.where((logs) => logs.isNotEmpty)
.listen(
(logs) {
logs.forEach((log) {
outputs
.where((output) => output.where(log))
.forEach((output) => output.emit(log));
});
},
);
});
} else {
_streamController.stream.listen((log) {
outputs
.where((output) => output.where(log))
.forEach((output) => output.emit(log));
});
}
}