github.com/grailbio/base@v0.0.11/grail/log.go (about) 1 package grail 2 3 import ( 4 "github.com/grailbio/base/log" 5 "v.io/x/lib/vlog" 6 ) 7 8 // VlogOutputter implements base/log.Outputter backed by vlog. 9 type VlogOutputter struct{} 10 11 func (VlogOutputter) Level() log.Level { 12 if vlog.V(1) { 13 return log.Debug 14 } else { 15 return log.Info 16 } 17 } 18 19 func (VlogOutputter) Output(calldepth int, level log.Level, s string) error { 20 // Notice that we do not add 1 to the call depth. In vlog, 0 depth means 21 // that the caller's file/line will be used. This is different from the log 22 // and github.com/grailbio/base/log packages, where that's the behavior you 23 // get with depth 1. 24 switch level { 25 case log.Off: 26 case log.Error: 27 vlog.ErrorDepth(calldepth, s) 28 case log.Info: 29 vlog.InfoDepth(calldepth, s) 30 default: 31 vlog.VI(vlog.Level(level)).InfoDepth(calldepth, s) 32 } 33 return nil 34 }