You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just create an instance of `Logger` and start logging:
24
+
23
25
```dart
24
26
var logger = Logger();
25
27
@@ -77,32 +79,35 @@ If you use the `PrettyPrinter`, there are more options:
77
79
```dart
78
80
var logger = Logger(
79
81
printer: PrettyPrinter(
80
-
methodCount: 2, // number of method calls to be displayed
81
-
errorMethodCount: 8, // number of method calls if stacktrace is provided
82
-
lineLength: 120, // width of the output
83
-
colors: true, // Colorful log messages
84
-
printEmojis: true, // Print an emoji for each log message
85
-
printTime: false // Should each log print contain a timestamp
82
+
methodCount: 2, // Number of method calls to be displayed
83
+
errorMethodCount: 8, // Number of method calls if stacktrace is provided
84
+
lineLength: 120, // Width of the output
85
+
colors: true, // Colorful log messages
86
+
printEmojis: true, // Print an emoji for each log message
87
+
printTime: false // Should each log print contain a timestamp
86
88
),
87
89
);
88
90
```
89
91
90
92
### Auto detecting
91
93
92
-
With the `io` package you can auto detect the `lineLength` and `colors` arguments.
93
-
Assuming you have imported the `io` package with `import 'dart:io' as io;` you
94
-
can auto detect `colors` with `io.stdout.supportsAnsiEscapes` and `lineLength`
94
+
With the `io` package you can auto detect the `lineLength` and `colors` arguments.
95
+
Assuming you have imported the `io` package with `import 'dart:io' as io;` you
96
+
can auto detect `colors` with `io.stdout.supportsAnsiEscapes` and `lineLength`
95
97
with `io.stdout.terminalColumns`.
96
98
97
-
You should probably do this unless there's a good reason you don't want to
99
+
You should probably do this unless there's a good reason you don't want to
98
100
import `io`, for example when using this library on the web.
99
101
100
102
## LogFilter
101
103
102
104
The `LogFilter` decides which log events should be shown and which don't.<br>
103
-
The default implementation (`DevelopmentFilter`) shows all logs with `level >= Logger.level` while in debug mode. In release mode all logs are omitted.
105
+
The default implementation (`DevelopmentFilter`) shows all logs with `level >= Logger.level` while
106
+
in debug mode.
107
+
In release mode all logs are omitted.
104
108
105
109
You can create your own `LogFilter` like this:
110
+
106
111
```dart
107
112
class MyFilter extends LogFilter {
108
113
@override
@@ -111,15 +116,16 @@ class MyFilter extends LogFilter {
111
116
}
112
117
}
113
118
```
114
-
This will show all logs even in release mode. (**NOT** a good idea)
115
119
120
+
This will show all logs even in release mode. (**NOT** a good idea)
116
121
117
122
## LogPrinter
118
123
119
124
The `LogPrinter` creates and formats the output, which is then sent to the `LogOutput`.<br>
120
125
You can implement your own `LogPrinter`. This gives you maximum flexibility.
121
126
122
127
A very basic printer could look like this:
128
+
123
129
```dart
124
130
class MyPrinter extends LogPrinter {
125
131
@override
@@ -129,7 +135,9 @@ class MyPrinter extends LogPrinter {
129
135
}
130
136
```
131
137
132
-
If you created a cool `LogPrinter` which might be helpful to others, feel free to open a pull request. :)
138
+
If you created a cool `LogPrinter` which might be helpful to others, feel free to open a pull
139
+
request.
140
+
:)
133
141
134
142
### Colors
135
143
@@ -144,7 +152,7 @@ decorator to achieved colored logs for any logger:
@@ -164,12 +172,14 @@ class ConsoleOutput extends LogOutput {
164
172
}
165
173
```
166
174
167
-
Possible future `LogOutput`s could send to a file, firebase or to Logcat. Feel free to open pull requests.
168
-
175
+
Possible future `LogOutput`s could send to a file, firebase or to Logcat. Feel free to open pull
176
+
requests.
169
177
170
178
## logger_flutter extension
171
179
172
-
The [logger_flutter](https://pub.dev/packages/logger_flutter) package is an extension for logger. You can add it to any Flutter app. Just shake the phone to show the console.
180
+
The [logger_flutter](https://pub.dev/packages/logger_flutter) package is an extension for logger.
0 commit comments