Skip to content

Enabled + stack unwinding #215

@pohly

Description

@pohly

RuntimeInfo.CallDepth is documented as:

	// CallDepth is the number of call frames the logr library adds between the
	// end-user and the LogSink.  LogSink implementations which choose to print
	// the original logging site (e.g. file & line) should climb this many
	// additional frames to find it.

It's 1, which is correct for the LogSink.Info and LogSink.Error calls, e.g.

logr/logr.go

Line 278 in eea184c

l.sink.Info(l.level, msg, keysAndValues...)

But it is not correct for the LogSink.Enabled call in Logger.Info:

logr/logr.go

Line 274 in eea184c

if l.Enabled() {

There the call chain is <user code> -> Logger.Info -> Logger.Enabled -> LogSink.Enabled.

It is correct again for <user code> -> Logger.Enabled -> LogSink.Enabled.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions