@@ -25,7 +25,7 @@ class PrettyPrinter extends LogPrinter {
2525 static const doubleDivider = '─' ;
2626 static const singleDivider = '┄' ;
2727
28- static final levelColors = {
28+ static final Map < Level , AnsiColor > defaultLevelColors = {
2929 Level .trace: AnsiColor .fg (AnsiColor .grey (0.5 )),
3030 Level .debug: const AnsiColor .none (),
3131 Level .info: const AnsiColor .fg (12 ),
@@ -34,13 +34,13 @@ class PrettyPrinter extends LogPrinter {
3434 Level .fatal: const AnsiColor .fg (199 ),
3535 };
3636
37- static final levelEmojis = {
37+ static final Map < Level , String > defaultLevelEmojis = {
3838 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: '👾' ,
4444 };
4545
4646 /// Matches a stacktrace line as generated on Android/iOS devices.
@@ -173,6 +173,16 @@ class PrettyPrinter extends LogPrinter {
173173 String _middleBorder = '' ;
174174 String _bottomBorder = '' ;
175175
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+
176186 PrettyPrinter ({
177187 this .stackTraceBeginIndex = 0 ,
178188 this .methodCount = 2 ,
@@ -184,6 +194,8 @@ class PrettyPrinter extends LogPrinter {
184194 this .excludeBox = const {},
185195 this .noBoxingByDefault = false ,
186196 this .excludePaths = const [],
197+ this .levelColors,
198+ this .levelEmojis,
187199 }) {
188200 _startTime ?? = DateTime .now ();
189201
@@ -355,19 +367,21 @@ class PrettyPrinter extends LogPrinter {
355367 }
356368
357369 AnsiColor _getLevelColor (Level level) {
370+ AnsiColor ? color;
358371 if (colors) {
359- return levelColors[level]! ;
360- } else {
361- return const AnsiColor .none ();
372+ color = levelColors? [level] ?? defaultLevelColors[level];
362373 }
374+ return color ?? const AnsiColor .none ();
363375 }
364376
365377 String _getEmoji (Level level) {
366378 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+ }
370383 }
384+ return '' ;
371385 }
372386
373387 List <String > _formatAndPrint (
0 commit comments