github.com/status-im/status-go@v1.1.0/logutils/stdhandler.go (about)

     1  package logutils
     2  
     3  import (
     4  	stdlog "log"
     5  
     6  	"github.com/ethereum/go-ethereum/log"
     7  )
     8  
     9  // NewStdHandler returns handler that uses logger from golang std lib.
    10  func NewStdHandler(fmtr log.Format) log.Handler {
    11  	return log.FuncHandler(func(r *log.Record) error {
    12  		line := fmtr.Format(r)
    13  		// 8 is a number of frames that will be skipped when log is printed.
    14  		// this is needed to show the file (with line number) where call to a logger was made
    15  		return stdlog.Output(8, string(line))
    16  	})
    17  }