1
- <img src =" https://raw.githubusercontent.com/leisim/logger/master/art/logo.svg?sanitize=true " width =" 200 " />
2
-
3
- <hr >
1
+ # Logger
4
2
5
3
[ ![ Travis] ( https://img.shields.io/travis/com/leisim/logger/master.svg )] ( https://travis-ci.com/leisim/logger ) [ ![ Version] ( https://img.shields.io/pub/v/logger.svg )] ( https://pub.dev/packages/logger ) ![ Runtime] ( https://img.shields.io/badge/dart-%3E%3D2.1-brightgreen.svg ) ![ GitHub license] ( https://img.shields.io/badge/license-MIT-blue.svg?style=flat )
6
4
@@ -85,14 +83,14 @@ var logger = Logger(
85
83
86
84
## LogFilter
87
85
88
- The ` LogFilter ` decides which logs should be shown and which don't.
86
+ The ` LogFilter ` decides which log events should be shown and which don't.< br >
89
87
The default implementation (` DebugFilter ` ) shows all logs with ` level >= Logger.level ` while in debug mode. In release mode all logs are omitted.
90
88
91
89
You can create your own ` LogFilter ` like this:
92
90
``` dart
93
91
class MyFilter extends LogFilter {
94
92
@override
95
- bool shouldLog(Level level, dynamic message, [dynamic error, StackTrace stackTrace] ) {
93
+ bool shouldLog(LogEvent event ) {
96
94
return true;
97
95
}
98
96
}
@@ -102,13 +100,15 @@ This will show all logs even in release mode. (**NOT** a good idea)
102
100
103
101
## LogPrinter
104
102
105
- You can implement your own ` LogPrinter ` . This gives you maximum flexibility. A very basic printer could look like this:
103
+ The ` LogPrinter ` creates and formats the output, which is then sent to the ` LogOutput ` .<br >
104
+ You can implement your own ` LogPrinter ` . This gives you maximum flexibility.
106
105
106
+ A very basic printer could look like this:
107
107
``` dart
108
108
class MyPrinter extends LogPrinter {
109
109
@override
110
- void log(Level level, dynamic message, dynamic error, StackTrace stackTrace ) {
111
- println(message);
110
+ void log(LogEvent event ) {
111
+ println(event. message);
112
112
}
113
113
}
114
114
```
@@ -120,13 +120,14 @@ If you created a cool `LogPrinter` which might be helpful to others, feel free t
120
120
121
121
## LogOutput
122
122
123
- ` LogOutput ` sends the log lines to the desired destination. The default implementation (` ConsoleOutput ` ) send every line to the system console.
123
+ ` LogOutput ` sends the log lines to the desired destination.<br >
124
+ The default implementation (` ConsoleOutput ` ) send every line to the system console.
124
125
125
126
``` dart
126
127
class ConsoleOutput extends LogOutput {
127
128
@override
128
- void output(Level level, List<String> lines ) {
129
- for (var line in lines) {
129
+ void output(OutputEvent event ) {
130
+ for (var line in event. lines) {
130
131
print(line);
131
132
}
132
133
}
0 commit comments