glog.go
func (l *Log) VDepth(depth int, level Level) bool {
	// This function tries hard to be cheap unless there's work to do.
	// The fast path is two atomic loads and compares.

	// Here is a cheap but safe test to see if V logging is enabled globally.
	if l.verbosity.get() >= level {
		return true
	}

	// It's off globally but it vmodule may still be set.
	// Here is another cheap but safe test to see if vmodule is enabled.
	if atomic.LoadInt32(&l.filterLength) > 0 {
		// Now we need a proper lock to use the logging structure. The pcs field
		// is shared so we must lock before accessing it. This is fairly expensive,
		// but if V logging is enabled we're slow anyway.
		l.mu.Lock()
		defer l.mu.Unlock()
		// Note that runtime.Callers counts skip differently to
		// runtime.Caller - i.e. it is one greater than the skip
		// value for .Caller to reach the same stack frame. So, even though
		// we are one level closer to the caller here, we will still use the
		// same value as for runtime.Caller!
		if runtime.Callers(l.skip+depth, l.pcs[:]) == 0 {
			return false
		}
		v, ok := l.vmap[l.pcs[0]]
		if !ok {
			v = l.setV(l.pcs[0])
		}
		return v >= level
	}
	return false
}
func (l *Log) VDepth(depth int, level Level) bool {
	// This function tries hard to be cheap unless there's work to do.
	// The fast path is two atomic loads and compares.

	// Here is a cheap but safe test to see if V logging is enabled globally.
	if l.verbosity.get() >= level {
		return true
	}

	// It's off globally but it vmodule may still be set.
	// Here is another cheap but safe test to see if vmodule is enabled.
	if atomic.LoadInt32(&l.filterLength) > 0 {
		// Now we need a proper lock to use the logging structure. The pcs field
		// is shared so we must lock before accessing it. This is fairly expensive,
		// but if V logging is enabled we're slow anyway.
		l.mu.Lock()
		defer l.mu.Unlock()
		// Note that runtime.Callers counts skip differently to
		// runtime.Caller - i.e. it is one greater than the skip
		// value for .Caller to reach the same stack frame. So, even though
		// we are one level closer to the caller here, we will still use the
		// same value as for runtime.Caller!
		if runtime.Callers(l.skip+depth, l.pcs[:]) == 0 {
			return false
		}
		v, ok := l.vmap[l.pcs[0]]
		if !ok {
			v = l.setV(l.pcs[0])
		}
		return v >= level
	}
	return false
}
func ( l * Log ) VDepth ( depth int , level Level ) bool { // This function tries hard to be cheap unless there's work to do. // The fast path is two atomic loads and compares. // Here is a cheap but safe test to see if V logging is enabled globally. if l . verbosity . get ( ) >= level { return true } // It's off globally but it vmodule may still be set. // Here is another cheap but safe test to see if vmodule is enabled. if atomic . LoadInt32 ( & l . filterLength ) > 0 { // Now we need a proper lock to use the logging structure. The pcs field // is shared so we must lock before accessing it. This is fairly expensive, // but if V logging is enabled we're slow anyway. l . mu . Lock ( ) defer l . mu . Unlock ( ) // Note that runtime.Callers counts skip differently to // runtime.Caller - i.e. it is one greater than the skip // value for .Caller to reach the same stack frame. So, even though // we are one level closer to the caller here, we will still use the // same value as for runtime.Caller! if runtime . Callers ( l . skip + depth , l . pcs [ : ] ) == 0 { return false } v , ok := l . vmap [ l . pcs [ 0 ] ] if ! ok { v = l . setV ( l . pcs [ 0 ] ) } return v >= level } return false }
// V reports whether verbosity at the call site is at least the requested level.
// The returned value is a boolean of type Verbose, which implements Info, Infoln
// and Infof. These methods will write to the Info log if called.
// Thus, one may write either
//	if glog.V(2) { glog.Info("log this") }
// or
//	glog.V(2).Info("log this")
// The second form is shorter but the first is cheaper if logging is off because it does
// not evaluate its arguments.
//
// Whether an individual call to V generates a log record depends on the setting of
// the -v and --vmodule flags; both are off by default. If the level in the call to
// V is at least the value of -v, or of -vmodule for the source file containing the
// call, the V call will log.
V reports whether verbosity at the call site is at least the requested level . The returned value is a boolean of type Verbose which implements Info Infoln and Infof . These methods will write to the Info log if called . Thus one may write either if glog . V ( 2 ) { glog . Info ( log this ) } or glog . V ( 2 ) . Info ( log this ) The second form is shorter but the first is cheaper if logging is off because it does not evaluate its arguments . Whether an individual call to V generates a log record depends on the setting of the - v and -- vmodule flags ; both are off by default . If the level in the call to V is at least the value of - v or of - vmodule for the source file containing the call the V call will log .