Skip to content

Commit cc0c86d

Browse files
defuncarthaarts
authored andcommitted
Add stackTraceBeginIndex setting in PrettyPrinter.
1 parent 66d2c57 commit cc0c86d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/src/printers/pretty_printer.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class PrettyPrinter extends LogPrinter {
6363

6464
static DateTime? _startTime;
6565

66+
/// The index which to begin the stack trace at
67+
///
68+
/// This can be useful if, for instance, Logger is wrapped in another class and
69+
/// you wish to remove these wrapped calls from stack trace
70+
final int stackTraceBeginIndex;
6671
final int methodCount;
6772
final int errorMethodCount;
6873
final int lineLength;
@@ -75,6 +80,7 @@ class PrettyPrinter extends LogPrinter {
7580
String _bottomBorder = '';
7681

7782
PrettyPrinter({
83+
this.stackTraceBeginIndex = 0,
7884
this.methodCount = 2,
7985
this.errorMethodCount = 8,
8086
this.lineLength = 120,
@@ -127,6 +133,9 @@ class PrettyPrinter extends LogPrinter {
127133

128134
String? formatStackTrace(StackTrace? stackTrace, int methodCount) {
129135
var lines = stackTrace.toString().split('\n');
136+
if (stackTraceBeginIndex > 0) {
137+
lines = lines.sublist(stackTraceBeginIndex);
138+
}
130139
var formatted = <String>[];
131140
var count = 0;
132141
for (var line in lines) {

0 commit comments

Comments
 (0)