@@ -25,7 +25,7 @@ class PrettyPrinter extends LogPrinter {
25
25
static const doubleDivider = '─' ;
26
26
static const singleDivider = '┄' ;
27
27
28
- static final levelColors = {
28
+ static final Map < Level , AnsiColor > defaultLevelColors = {
29
29
Level .trace: AnsiColor .fg (AnsiColor .grey (0.5 )),
30
30
Level .debug: const AnsiColor .none (),
31
31
Level .info: const AnsiColor .fg (12 ),
@@ -34,13 +34,13 @@ class PrettyPrinter extends LogPrinter {
34
34
Level .fatal: const AnsiColor .fg (199 ),
35
35
};
36
36
37
- static final levelEmojis = {
37
+ static final Map < Level , String > defaultLevelEmojis = {
38
38
Level .trace: '' ,
39
- Level .debug: '🐛 ' ,
40
- Level .info: '💡 ' ,
41
- Level .warning: '⚠️ ' ,
42
- Level .error: '⛔ ' ,
43
- Level .fatal: '👾 ' ,
39
+ Level .debug: '🐛' ,
40
+ Level .info: '💡' ,
41
+ Level .warning: '⚠️' ,
42
+ Level .error: '⛔' ,
43
+ Level .fatal: '👾' ,
44
44
};
45
45
46
46
/// Matches a stacktrace line as generated on Android/iOS devices.
@@ -173,6 +173,16 @@ class PrettyPrinter extends LogPrinter {
173
173
String _middleBorder = '' ;
174
174
String _bottomBorder = '' ;
175
175
176
+ /// Controls the colors used for the different log levels.
177
+ ///
178
+ /// Default fallbacks are modifiable via [defaultLevelColors] .
179
+ final Map <Level , AnsiColor >? levelColors;
180
+
181
+ /// Controls the emojis used for the different log levels.
182
+ ///
183
+ /// Default fallbacks are modifiable via [defaultLevelEmojis] .
184
+ final Map <Level , String >? levelEmojis;
185
+
176
186
PrettyPrinter ({
177
187
this .stackTraceBeginIndex = 0 ,
178
188
this .methodCount = 2 ,
@@ -184,6 +194,8 @@ class PrettyPrinter extends LogPrinter {
184
194
this .excludeBox = const {},
185
195
this .noBoxingByDefault = false ,
186
196
this .excludePaths = const [],
197
+ this .levelColors,
198
+ this .levelEmojis,
187
199
}) {
188
200
_startTime ?? = DateTime .now ();
189
201
@@ -355,19 +367,21 @@ class PrettyPrinter extends LogPrinter {
355
367
}
356
368
357
369
AnsiColor _getLevelColor (Level level) {
370
+ AnsiColor ? color;
358
371
if (colors) {
359
- return levelColors[level]! ;
360
- } else {
361
- return const AnsiColor .none ();
372
+ color = levelColors? [level] ?? defaultLevelColors[level];
362
373
}
374
+ return color ?? const AnsiColor .none ();
363
375
}
364
376
365
377
String _getEmoji (Level level) {
366
378
if (printEmojis) {
367
- return levelEmojis[level]! ;
368
- } else {
369
- return '' ;
379
+ final String ? emoji = levelEmojis? [level] ?? defaultLevelEmojis[level];
380
+ if (emoji != null ) {
381
+ return '$emoji ' ;
382
+ }
370
383
}
384
+ return '' ;
371
385
}
372
386
373
387
List <String > _formatAndPrint (
0 commit comments