1 | | | import 'package:logger/web.dart'; |
2 | | |
|
3 | | | class InternalLogger extends Logger { |
4 | | 10 | InternalLogger() |
5 | | 9 | : super( |
6 | | 9 | filter: _LogAllFilter(), |
7 | | 9 | printer: _DummyPrinter(), |
8 | | 9 | output: _NoLogOutput(), |
9 | | | ); |
10 | | | } |
11 | | |
|
12 | | 1 | class _NoLogOutput extends LogOutput { |
13 | | 9 | @override |
14 | | 0 | void output(OutputEvent event) { |
15 | | | // Do nothing in this logger (which lives in the worker thread). |
16 | | | // The log event will be captured and forwarded to the channelLogger (which |
17 | | | // lives in the main thread). |
18 | | 0 | } |
19 | | | } |
20 | | |
|
21 | | 1 | class _DummyPrinter extends LogPrinter { |
22 | | 9 | @override |
23 | | 0 | List<String> log(LogEvent event) => |
24 | | | // Logger will ignore log events that produce an empty array. |
25 | | | // Make sure the array is not empty so the log event is notified |
26 | | | // through Logger's output callbacks. |
27 | | 0 | const ['']; |
28 | | | } |
29 | | |
|
30 | | 1 | class _LogAllFilter extends LogFilter { |
31 | | 9 | @override |
32 | | 0 | bool shouldLog(LogEvent event) => |
33 | | | // Log everything. It's up to the receiving channelLogger to decide |
34 | | | // whether the message should be logged or not. |
35 | | 0 | true; |
36 | | | } |