// V will returns a logger which will discard output if the specified level is greater than the current logging level. func (f *FileLogger) V(level int32) VerboseLogger { // Is the loglevel set verbose enough to accept the forthcoming log statement if log.V(log.Level(level)) { return f } // Otherwise discard return None }
func getLogLevel() (level int) { for level = 5; level >= 0; level-- { if glog.V(glog.Level(level)) == true { break } } return }
func (r *diagnosticResultImpl) appendLogs(stackDepth int, entry ...log.Entry) { if r.logs == nil { r.logs = make([]log.Entry, 0) } r.logs = append(r.logs, entry...) // glog immediately for debugging when a diagnostic silently chokes for _, entry := range entry { if glog.V(glog.Level(6 - entry.Level.Level)) { glog.InfoDepth(stackDepth, entry.Message) } } }
func (f *FileLogger) writeln(sev severity, line string) { severity := severities[sev] // If the loglevel has been elevated above this file logger's verbosity (generally set to 2) // then delegate ALL messages to elevated logger in order to leverage its file/line/timestamp // prefix information. if log.V(log.Level(f.level + 1)) { severity.delegateFn(3, line) } else { // buf.io is not threadsafe, so serialize access to the stream f.mutex.Lock() defer f.mutex.Unlock() f.w.WriteString(severity.prefix) f.w.WriteString(line) if !strings.HasSuffix(line, "\n") { f.w.WriteByte('\n') } f.w.Flush() } }
func NewLibraryLogger(level int32, prefix string) *LibraryLogger { return &LibraryLogger{ V: glog.Level(level), Prefix: prefix, } }
// NewGLogWriterV returns a new Writer that delegates to `glog.Info` at the // desired level of verbosity func NewGLogWriterV(level int) io.Writer { return &gLogWriter{ level: glog.Level(level), } }
// V wraps glog.V. See that documentation for details. func V(level Level) Verbose { return Verbose(glog.V(glog.Level(level))) }