@@ -44,50 +44,124 @@ class PrettyPrinter extends LogPrinter {
44
44
};
45
45
46
46
/// Matches a stacktrace line as generated on Android/iOS devices.
47
+ ///
47
48
/// For example:
48
- /// #1 Logger.log (package:logger/src/logger.dart:115:29)
49
+ /// * #1 Logger.log (package:logger/src/logger.dart:115:29)
49
50
static final _deviceStackTraceRegex =
50
51
RegExp (r'#[0-9]+[\s]+(.+) \(([^\s]+)\)' );
51
52
52
53
/// Matches a stacktrace line as generated by Flutter web.
54
+ ///
53
55
/// For example:
54
- /// packages/logger/src/printers/pretty_printer.dart 91:37
56
+ /// * packages/logger/src/printers/pretty_printer.dart 91:37
55
57
static final _webStackTraceRegex =
56
58
RegExp (r'^((packages|dart-sdk)\/[^\s]+\/)' );
57
59
58
60
/// Matches a stacktrace line as generated by browser Dart.
61
+ ///
59
62
/// For example:
60
- /// dart:sdk_internal
61
- /// package:logger/src/logger.dart
63
+ /// * dart:sdk_internal
64
+ /// * package:logger/src/logger.dart
62
65
static final _browserStackTraceRegex =
63
66
RegExp (r'^(?:package:)?(dart:[^\s]+|[^\s]+)' );
64
67
65
68
static DateTime ? _startTime;
66
69
67
- /// The index which to begin the stack trace at
70
+ /// The index at which the stack trace should start.
68
71
///
69
72
/// This can be useful if, for instance, Logger is wrapped in another class and
70
73
/// you wish to remove these wrapped calls from stack trace
74
+ ///
75
+ /// See also:
76
+ /// * [excludePaths]
71
77
final int stackTraceBeginIndex;
78
+
79
+ /// Controls the method count in created stack traces.
80
+ ///
81
+ /// This is used when no stack trace has been provided.
82
+ ///
83
+ /// Set to `0` to disable the creation of a stack trace.
84
+ ///
85
+ /// See also:
86
+ /// * [errorMethodCount]
72
87
final int methodCount;
88
+
89
+ /// Controls the method count in provided stack traces.
90
+ ///
91
+ /// This is used when a stack trace was provided via the error parameter.
92
+ ///
93
+ /// Set to `0` in order to disable printing the provided stack trace.
94
+ ///
95
+ /// See also:
96
+ /// * [methodCount]
73
97
final int errorMethodCount;
98
+
99
+ /// Controls the length of the divider lines.
74
100
final int lineLength;
101
+
102
+ /// Whether ansi colors are used to color the output.
75
103
final bool colors;
104
+
105
+ /// Whether emojis are prefixed to the log line.
76
106
final bool printEmojis;
107
+
108
+ /// Whether [LogEvent.time] is printed.
77
109
final bool printTime;
78
110
79
- /// To prevent ascii 'boxing' of any log [Level] include the level in map for excludeBox,
80
- /// for example to prevent boxing of [Level.verbose] and [Level.info] use excludeBox:{Level.verbose:true, Level.info:true}
111
+ /// Controls the ascii 'boxing' of different [Level] s.
112
+ ///
113
+ /// By default all levels are 'boxed',
114
+ /// to prevent 'boxing' of a specific level,
115
+ /// include it with `true` in the map.
116
+ ///
117
+ /// Example to prevent boxing of [Level.verbose] and [Level.info] :
118
+ /// ```dart
119
+ /// excludeBox: {
120
+ /// Level.verbose: true,
121
+ /// Level.info: true,
122
+ /// },
123
+ /// ```
124
+ ///
125
+ /// See also:
126
+ /// * [noBoxingByDefault]
81
127
final Map <Level , bool > excludeBox;
82
128
83
- /// To make the default for every level to prevent boxing entirely set [noBoxingByDefault] to true
84
- /// (boxing can still be turned on for some levels by using something like excludeBox:{Level.error:false} )
129
+ /// Whether the implicit `bool` s in [excludeBox] are `true` or `false` by default.
130
+ ///
131
+ /// By default all levels are 'boxed',
132
+ /// this flips the default to no boxing for all levels.
133
+ /// Individual boxing can still be turned on for specific
134
+ /// levels by setting them manually to `false` in [excludeBox] .
135
+ ///
136
+ /// Example to specifically activate 'boxing' of [Level.error] :
137
+ /// ```dart
138
+ /// noBoxingByDefault: true,
139
+ /// excludeBox: {
140
+ /// Level.error: false,
141
+ /// },
142
+ /// ```
143
+ ///
144
+ /// See also:
145
+ /// * [excludeBox]
85
146
final bool noBoxingByDefault;
86
147
87
- /// To exclude user's custom path
88
- /// for example if you made a Mylog util redirect to logger.log,
89
- /// you can add your Mylog path in [excludePaths] .
148
+ /// A list of custom paths that are excluded from the stack trace.
149
+ ///
150
+ /// For example, to exclude your `MyLog` util that redirects to this logger:
151
+ /// ```dart
152
+ /// excludePaths: [
153
+ /// // To exclude a whole package
154
+ /// "package:test",
155
+ /// // To exclude a single file
156
+ /// "package:test/util/my_log.dart",
157
+ /// ],
158
+ /// ```
159
+ ///
160
+ /// See also:
161
+ /// * [stackTraceBeginIndex]
90
162
final List <String > excludePaths;
163
+
164
+ /// Contains the parsed rules resulting from [excludeBox] and [noBoxingByDefault] .
91
165
late final Map <Level , bool > includeBox;
92
166
93
167
String _topBorder = '' ;
0 commit comments