Skip to content

Commit 7d6ce72

Browse files
committed
Error level includes Error() of err
This changes the output of the .Error() method to include the error message.
1 parent d490b39 commit 7d6ce72

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

buflogr.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (l *bufLogger) Info(level int, msg string, kv ...interface{}) {
7777
// Error implements logr.Logger.Error by prefixing the line with "ERROR" and
7878
// write it to the internal buffer.
7979
func (l *bufLogger) Error(err error, msg string, kv ...interface{}) {
80-
l.writeLine(LevelError, msg, kv...)
80+
l.writeLine(fmt.Sprintf("%s %v", LevelError, err), msg, kv...)
8181
}
8282

8383
// WithValues returns a new LogSink with additional key/value pairs.

example/example_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func ExampleNew() {
4141
// INFO MyName hello module example val1 1 val2 map[k:1]
4242
// V[1] MyName you should see this module example
4343
// V[2] MyName you will also see this module example
44-
// ERROR MyName uh oh module example trouble true reasons [0.1 0.11 3.14]
45-
// ERROR MyName goodbye module example code -1
44+
// ERROR <nil> MyName uh oh module example trouble true reasons [0.1 0.11 3.14]
45+
// ERROR an error occurred MyName goodbye module example code -1
4646
// INFO MyName thru a helper module example
4747
}
4848

0 commit comments

Comments
 (0)