Skip to content

Commit

Permalink
Merge pull request ethereum#103 from status-im/chore/make_logger_writ…
Browse files Browse the repository at this point in the history
…e_public

[logger] add func `Output` as a convenient alias for write
  • Loading branch information
qfrank authored Nov 8, 2023
2 parents f9323e3 + 79bd6b7 commit 2372a59
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ type logger struct {
h *swapHandler
}

// Output is a convenient alias for write, allowing for the modification of
// the callDepth (number of stack frames to skip).
// callDepth influences the reported line number of the log message.
// A callDepth of zero reports the immediate caller of Output.
// Non-zero callDepth skips as many stack frames.
func (l *logger) Output(msg string, lvl Lvl, callDepth int, ctx ...interface{}) {
l.write(msg, lvl, ctx, callDepth+skipLevel)
}

func (l *logger) write(msg string, lvl Lvl, ctx []interface{}, skip int) {
l.h.Log(&Record{
Time: time.Now(),
Expand Down

0 comments on commit 2372a59

Please sign in to comment.