File tree Expand file tree Collapse file tree 2 files changed +28
-9
lines changed Expand file tree Collapse file tree 2 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ class LogfmtPrinter extends LogPrinter {
29
29
}
30
30
});
31
31
}
32
+ if (event.error != null ) {
33
+ output.write (' error="${event .error }"' );
34
+ }
32
35
33
36
return [output.toString ()];
34
37
}
Original file line number Diff line number Diff line change 1
- import 'package:test/test.dart' ;
2
1
import 'package:logger/logger.dart' ;
2
+ import 'package:test/test.dart' ;
3
3
4
4
void main () {
5
5
var printer = LogfmtPrinter ();
@@ -18,13 +18,14 @@ void main() {
18
18
19
19
test ('with a string message includes a msg key' , () {
20
20
expect (
21
- printer.log (LogEvent (
22
- Level .debug,
23
- 'some message' ,
24
- Exception ('boom' ),
25
- StackTrace .current,
26
- ))[0 ],
27
- contains ('msg="some message"' ));
21
+ printer.log (LogEvent (
22
+ Level .debug,
23
+ 'some message' ,
24
+ Exception ('boom' ),
25
+ StackTrace .current,
26
+ ))[0 ],
27
+ contains ('msg="some message"' ),
28
+ );
28
29
});
29
30
30
31
test ('includes random key=value pairs' , () {
@@ -39,6 +40,21 @@ void main() {
39
40
expect (output, contains ('foo="bar baz"' ));
40
41
});
41
42
43
+ test ('handles an error/exception' , () {
44
+ var output = printer.log (LogEvent (
45
+ Level .debug,
46
+ 'some message' ,
47
+ Exception ('boom' ),
48
+ StackTrace .current,
49
+ ))[0 ];
50
+ expect (output, contains ('error="Exception: boom"' ));
51
+
52
+ output = printer.log (LogEvent (
53
+ Level .debug,
54
+ 'some message' ,
55
+ ))[0 ];
56
+ expect (output, isNot (contains ('error=' )));
57
+ });
58
+
42
59
test ('handles a stacktrace' , () {}, skip: 'TODO' );
43
- test ('handles an error/exception' , () {}, skip: 'TODO' );
44
60
}
You can’t perform that action at this time.
0 commit comments