Use InfoDepth/FatalDepth in glogger.go

This way, log messages will show the proper location where the log
statement originated, instead of "glogger.go:67" or something like that.
This commit is contained in:
Adam Michalik
2016-11-29 12:51:42 -08:00
parent 5e3de3f217
commit 4a119ee276

View File

@ -37,6 +37,8 @@ Package glogger defines glog-based logging for grpc.
package glogger
import (
"fmt"
"github.com/golang/glog"
"google.golang.org/grpc/grpclog"
)
@ -48,25 +50,25 @@ func init() {
type glogger struct{}
func (g *glogger) Fatal(args ...interface{}) {
glog.Fatal(args...)
glog.FatalDepth(2, args...)
}
func (g *glogger) Fatalf(format string, args ...interface{}) {
glog.Fatalf(format, args...)
glog.FatalDepth(2, fmt.Sprintf(format, args...))
}
func (g *glogger) Fatalln(args ...interface{}) {
glog.Fatalln(args...)
glog.FatalDepth(2, fmt.Sprintln(args...))
}
func (g *glogger) Print(args ...interface{}) {
glog.Info(args...)
glog.InfoDepth(2, args...)
}
func (g *glogger) Printf(format string, args ...interface{}) {
glog.Infof(format, args...)
glog.InfoDepth(2, fmt.Sprintf(format, args...))
}
func (g *glogger) Println(args ...interface{}) {
glog.Infoln(args...)
glog.InfoDepth(2, fmt.Sprintln(args...))
}