code
stringlengths 12
335k
| docstring
stringlengths 20
20.8k
| func_name
stringlengths 1
105
| language
stringclasses 1
value | repo
stringclasses 498
values | path
stringlengths 5
172
| url
stringlengths 43
235
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
func Exitf(format string, args ...interface{}) {
atomic.StoreUint32(&fatalNoStacks, 1)
logging.printf(fatalLog, format, args...)
} | Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1).
Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. | Exitf | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go | Apache-2.0 |
func shortHostname(hostname string) string {
if i := strings.Index(hostname, "."); i >= 0 {
return hostname[:i]
}
return hostname
} | shortHostname returns its argument, truncating at the first period.
For instance, given "www.google.com" it returns "www". | shortHostname | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/klog_file.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog_file.go | Apache-2.0 |
func logName(tag string, t time.Time) (name, link string) {
name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d",
program,
host,
userName,
tag,
t.Year(),
t.Month(),
t.Day(),
t.Hour(),
t.Minute(),
t.Second(),
pid)
return name, program + "." + tag
} | logName returns a new log file name containing tag, with start time t, and
the name for the symlink for tag. | logName | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/klog_file.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog_file.go | Apache-2.0 |
func create(tag string, t time.Time, startup bool) (f *os.File, filename string, err error) {
if logging.logFile != "" {
f, err := openOrCreate(logging.logFile, startup)
if err == nil {
return f, logging.logFile, nil
}
return nil, "", fmt.Errorf("log: unable to create log: %v", err)
}
onceLogDirs.Do(createLogDirs)
if len(logDirs) == 0 {
return nil, "", errors.New("log: no log dirs")
}
name, link := logName(tag, t)
var lastErr error
for _, dir := range logDirs {
fname := filepath.Join(dir, name)
f, err := openOrCreate(fname, startup)
if err == nil {
symlink := filepath.Join(dir, link)
os.Remove(symlink) // ignore err
os.Symlink(name, symlink) // ignore err
return f, fname, nil
}
lastErr = err
}
return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr)
} | create creates a new log file and returns the file and its filename, which
contains tag ("INFO", "FATAL", etc.) and t. If the file is created
successfully, create also attempts to update the symlink for that tag, ignoring
errors.
The startup argument indicates whether this is the initial startup of klog.
If startup is true, existing files are opened for appending instead of truncated. | create | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/klog_file.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog_file.go | Apache-2.0 |
func openOrCreate(name string, startup bool) (*os.File, error) {
if startup {
f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
return f, err
}
f, err := os.Create(name)
return f, err
} | The startup argument indicates whether this is the initial startup of klog.
If startup is true, existing files are opened for appending instead of truncated. | openOrCreate | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/klog_file.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog_file.go | Apache-2.0 |
func (ref ObjectRef) MarshalLog() interface{} {
type or ObjectRef
return or(ref)
} | MarshalLog ensures that loggers with support for structured output will log
as a struct by removing the String method via a custom type. | MarshalLog | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/k8s_references.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/k8s_references.go | Apache-2.0 |
func KObj(obj KMetadata) ObjectRef {
if obj == nil {
return ObjectRef{}
}
if val := reflect.ValueOf(obj); val.Kind() == reflect.Ptr && val.IsNil() {
return ObjectRef{}
}
return ObjectRef{
Name: obj.GetName(),
Namespace: obj.GetNamespace(),
}
} | KObj returns ObjectRef from ObjectMeta | KObj | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/k8s_references.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/k8s_references.go | Apache-2.0 |
func KRef(namespace, name string) ObjectRef {
return ObjectRef{
Name: name,
Namespace: namespace,
}
} | KRef returns ObjectRef from name and namespace | KRef | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/k8s_references.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/k8s_references.go | Apache-2.0 |
func KObjs(arg interface{}) []ObjectRef {
s := reflect.ValueOf(arg)
if s.Kind() != reflect.Slice {
return nil
}
objectRefs := make([]ObjectRef, 0, s.Len())
for i := 0; i < s.Len(); i++ {
if v, ok := s.Index(i).Interface().(KMetadata); ok {
objectRefs = append(objectRefs, KObj(v))
} else {
return nil
}
}
return objectRefs
} | KObjs returns slice of ObjectRef from an slice of ObjectMeta
DEPRECATED: Use KObjSlice instead, it has better performance. | KObjs | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/k8s_references.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/k8s_references.go | Apache-2.0 |
func KObjSlice(arg interface{}) interface{} {
return kobjSlice{arg: arg}
} | KObjSlice takes a slice of objects that implement the KMetadata interface
and returns an object that gets logged as a slice of ObjectRef values or a
string containing those values, depending on whether the logger prefers text
output or structured output.
An error string is logged when KObjSlice is not passed a suitable slice.
Processing of the argument is delayed until the value actually gets logged,
in contrast to KObjs where that overhead is incurred regardless of whether
the result is needed. | KObjSlice | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/k8s_references.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/k8s_references.go | Apache-2.0 |
func Format(obj interface{}) interface{} {
return formatAny{Object: obj}
} | Format wraps a value of an arbitrary type and implement fmt.Stringer and
logr.Marshaler for them. Stringer returns pretty-printed JSON. MarshalLog
returns the original value with a type that has no special methods, in
particular no MarshalLog or MarshalJSON.
Wrapping values like that is useful when the value has a broken
implementation of these special functions (for example, a type which
inherits String from TypeMeta, but then doesn't re-implement String) or the
implementation produces output that is less readable or unstructured (for
example, the generated String functions for Kubernetes API types). | Format | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/format.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/format.go | Apache-2.0 |
func (s *severityValue) get() severity.Severity {
return severity.Severity(atomic.LoadInt32((*int32)(&s.Severity)))
} | get returns the value of the severity. | get | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (s *severityValue) set(val severity.Severity) {
atomic.StoreInt32((*int32)(&s.Severity), int32(val))
} | set sets the value of the severity. | set | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (s *severityValue) String() string {
return strconv.FormatInt(int64(s.Severity), 10)
} | String is part of the flag.Value interface. | String | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (s *severityValue) Get() interface{} {
return s.Severity
} | Get is part of the flag.Getter interface. | Get | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (s *severityValue) Set(value string) error {
var threshold severity.Severity
// Is it a known name?
if v, ok := severity.ByName(value); ok {
threshold = v
} else {
v, err := strconv.ParseInt(value, 10, 32)
if err != nil {
return err
}
threshold = severity.Severity(v)
}
logging.stderrThreshold.set(threshold)
return nil
} | Set is part of the flag.Value interface. | Set | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (s *OutputStats) Lines() int64 {
return atomic.LoadInt64(&s.lines)
} | Lines returns the number of lines written. | Lines | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (s *OutputStats) Bytes() int64 {
return atomic.LoadInt64(&s.bytes)
} | Bytes returns the number of bytes written. | Bytes | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *Level) get() Level {
return Level(atomic.LoadInt32((*int32)(l)))
} | get returns the value of the Level. | get | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *Level) set(val Level) {
atomic.StoreInt32((*int32)(l), int32(val))
} | set sets the value of the Level. | set | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *Level) String() string {
return strconv.FormatInt(int64(*l), 10)
} | String is part of the flag.Value interface. | String | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *Level) Get() interface{} {
return *l
} | Get is part of the flag.Getter interface. | Get | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *Level) Set(value string) error {
v, err := strconv.ParseInt(value, 10, 32)
if err != nil {
return err
}
logging.mu.Lock()
defer logging.mu.Unlock()
logging.setVState(Level(v), logging.vmodule.filter, false)
return nil
} | Set is part of the flag.Value interface. | Set | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (m *modulePat) match(file string) bool {
if m.literal {
return file == m.pattern
}
match, _ := filepath.Match(m.pattern, file)
return match
} | match reports whether the file matches the pattern. It uses a string
comparison if the pattern contains no metacharacters. | match | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (m *moduleSpec) Get() interface{} {
return nil
} | Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the
struct is not exported. | Get | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (m *moduleSpec) Set(value string) error {
filter, err := parseModuleSpec(value)
if err != nil {
return err
}
logging.mu.Lock()
defer logging.mu.Unlock()
logging.setVState(logging.verbosity, filter, true)
return nil
} | Set will sets module value
Syntax: -vmodule=recordio=2,file=1,gfs*=3 | Set | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func isLiteral(pattern string) bool {
return !strings.ContainsAny(pattern, `\*?[]`)
} | isLiteral reports whether the pattern is a literal string, that is, has no metacharacters
that require filepath.Match to be called to match the pattern. | isLiteral | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (t *traceLocation) isSet() bool {
return t.line > 0
} | isSet reports whether the trace location has been specified.
logging.mu is held. | isSet | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (t *traceLocation) match(file string, line int) bool {
if t.line != line {
return false
}
if i := strings.LastIndex(file, "/"); i >= 0 {
file = file[i+1:]
}
return t.file == file
} | match reports whether the specified file and line matches the trace location.
The argument file name is the full path, not the basename specified in the flag.
logging.mu is held. | match | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (t *traceLocation) Get() interface{} {
return nil
} | Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the
struct is not exported | Get | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (t *traceLocation) Set(value string) error {
if value == "" {
// Unset.
logging.mu.Lock()
defer logging.mu.Unlock()
t.line = 0
t.file = ""
return nil
}
fields := strings.Split(value, ":")
if len(fields) != 2 {
return errTraceSyntax
}
file, line := fields[0], fields[1]
if !strings.Contains(file, ".") {
return errTraceSyntax
}
v, err := strconv.Atoi(line)
if err != nil {
return errTraceSyntax
}
if v <= 0 {
return errors.New("negative or zero value for level")
}
logging.mu.Lock()
defer logging.mu.Unlock()
t.line = v
t.file = file
return nil
} | Set will sets backtrace value
Syntax: -log_backtrace_at=gopherflakes.go:234
Note that unlike vmodule the file extension is included here. | Set | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func init() {
commandLine.StringVar(&logging.logDir, "log_dir", "", "If non-empty, write log files in this directory (no effect when -logtostderr=true)")
commandLine.StringVar(&logging.logFile, "log_file", "", "If non-empty, use this log file (no effect when -logtostderr=true)")
commandLine.Uint64Var(&logging.logFileMaxSizeMB, "log_file_max_size", 1800,
"Defines the maximum size a log file can grow to (no effect when -logtostderr=true). Unit is megabytes. "+
"If the value is 0, the maximum file size is unlimited.")
commandLine.BoolVar(&logging.toStderr, "logtostderr", true, "log to standard error instead of files")
commandLine.BoolVar(&logging.alsoToStderr, "alsologtostderr", false, "log to standard error as well as files (no effect when -logtostderr=true)")
logging.setVState(0, nil, false)
commandLine.Var(&logging.verbosity, "v", "number for the log level verbosity")
commandLine.BoolVar(&logging.addDirHeader, "add_dir_header", false, "If true, adds the file directory to the header of the log messages")
commandLine.BoolVar(&logging.skipHeaders, "skip_headers", false, "If true, avoid header prefixes in the log messages")
commandLine.BoolVar(&logging.oneOutput, "one_output", false, "If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)")
commandLine.BoolVar(&logging.skipLogHeaders, "skip_log_headers", false, "If true, avoid headers when opening log files (no effect when -logtostderr=true)")
logging.stderrThreshold = severityValue{
Severity: severity.ErrorLog, // Default stderrThreshold is ERROR.
}
commandLine.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=true)")
commandLine.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging")
commandLine.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace")
logging.settings.contextualLoggingEnabled = true
logging.flushD = newFlushDaemon(logging.lockAndFlushAll, nil)
} | init sets up the defaults and creates command line flags. | init | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func InitFlags(flagset *flag.FlagSet) {
if flagset == nil {
flagset = flag.CommandLine
}
commandLine.VisitAll(func(f *flag.Flag) {
flagset.Var(f.Value, f.Name, f.Usage)
})
} | InitFlags is for explicitly initializing the flags.
It may get called repeatedly for different flagsets, but not
twice for the same one. May get called concurrently
to other goroutines using klog. However, only some flags
may get set concurrently (see implementation). | InitFlags | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Flush() {
logging.lockAndFlushAll()
} | Flush flushes all pending log I/O. | Flush | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (s settings) deepCopy() settings {
// vmodule is a slice and would be shared, so we have copy it.
filter := make([]modulePat, len(s.vmodule.filter))
copy(filter, s.vmodule.filter)
s.vmodule.filter = filter
if s.logger != nil {
logger := *s.logger
s.logger = &logger
}
return s
} | deepCopy creates a copy that doesn't share anything with the original
instance. | deepCopy | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) setVState(verbosity Level, filter []modulePat, setFilter bool) {
// Turn verbosity off so V will not fire while we are in transition.
l.verbosity.set(0)
// Ditto for filter length.
atomic.StoreInt32(&l.filterLength, 0)
// Set the new filters and wipe the pc->Level map if the filter has changed.
if setFilter {
l.vmodule.filter = filter
l.vmap = make(map[uintptr]Level)
}
// Things are consistent now, so enable filtering and verbosity.
// They are enabled in order opposite to that in V.
atomic.StoreInt32(&l.filterLength, int32(len(filter)))
l.verbosity.set(verbosity)
} | setVState sets a consistent state for V logging.
l.mu is held. | setVState | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func CaptureState() State {
logging.mu.Lock()
defer logging.mu.Unlock()
return &state{
settings: logging.settings.deepCopy(),
flushDRunning: logging.flushD.isRunning(),
maxSize: MaxSize,
}
} | CaptureState gathers information about all current klog settings.
The result can be used to restore those settings. | CaptureState | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) formatHeader(s severity.Severity, file string, line int, now time.Time) *buffer.Buffer {
buf := buffer.GetBuffer()
if l.skipHeaders {
return buf
}
buf.FormatHeader(s, file, line, now)
return buf
} | formatHeader formats a log header using the provided file name and line number. | formatHeader | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) printWithFileLine(s severity.Severity, logger *logWriter, filter LogFilter, file string, line int, alsoToStderr bool, args ...interface{}) {
buf := l.formatHeader(s, file, line, timeNow())
// If a logger is set and doesn't support writing a formatted buffer,
// we clear the generated header as we rely on the backing
// logger implementation to print headers.
if logger != nil && logger.writeKlogBuffer == nil {
buffer.PutBuffer(buf)
buf = buffer.GetBuffer()
}
if filter != nil {
args = filter.Filter(args)
}
fmt.Fprint(buf, args...)
if buf.Bytes()[buf.Len()-1] != '\n' {
buf.WriteByte('\n')
}
l.output(s, logger, buf, 2 /* depth */, file, line, alsoToStderr)
} | printWithFileLine behaves like print but uses the provided file and line number. If
alsoLogToStderr is true, the log message always appears on standard error; it
will also appear in the log file unless --logtostderr is set. | printWithFileLine | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) errorS(err error, logger *logWriter, filter LogFilter, depth int, msg string, keysAndValues ...interface{}) {
if filter != nil {
msg, keysAndValues = filter.FilterS(msg, keysAndValues)
}
if logger != nil {
logger.WithCallDepth(depth+2).Error(err, msg, keysAndValues...)
return
}
l.printS(err, severity.ErrorLog, depth+1, msg, keysAndValues...)
} | if logger is specified, will call logger.Error, otherwise output with logging module. | errorS | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) infoS(logger *logWriter, filter LogFilter, depth int, msg string, keysAndValues ...interface{}) {
if filter != nil {
msg, keysAndValues = filter.FilterS(msg, keysAndValues)
}
if logger != nil {
logger.WithCallDepth(depth+2).Info(msg, keysAndValues...)
return
}
l.printS(nil, severity.InfoLog, depth+1, msg, keysAndValues...)
} | if logger is specified, will call logger.Info, otherwise output with logging module. | infoS | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) printS(err error, s severity.Severity, depth int, msg string, keysAndValues ...interface{}) {
// Only create a new buffer if we don't have one cached.
b := buffer.GetBuffer()
// The message is always quoted, even if it contains line breaks.
// If developers want multi-line output, they should use a small, fixed
// message and put the multi-line output into a value.
b.WriteString(strconv.Quote(msg))
if err != nil {
serialize.KVListFormat(&b.Buffer, "err", err)
}
serialize.KVListFormat(&b.Buffer, keysAndValues...)
l.printDepth(s, nil, nil, depth+1, &b.Buffer)
// Make the buffer available for reuse.
buffer.PutBuffer(b)
} | printS is called from infoS and errorS if logger is not specified.
set log severity by s | printS | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func SetOutput(w io.Writer) {
logging.mu.Lock()
defer logging.mu.Unlock()
for s := severity.FatalLog; s >= severity.InfoLog; s-- {
rb := &redirectBuffer{
w: w,
}
logging.file[s] = rb
}
} | SetOutput sets the output destination for all severities | SetOutput | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func SetOutputBySeverity(name string, w io.Writer) {
logging.mu.Lock()
defer logging.mu.Unlock()
sev, ok := severity.ByName(name)
if !ok {
panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name))
}
rb := &redirectBuffer{
w: w,
}
logging.file[sev] = rb
} | SetOutputBySeverity sets the output destination for specific severity | SetOutputBySeverity | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func LogToStderr(stderr bool) {
logging.mu.Lock()
defer logging.mu.Unlock()
logging.toStderr = stderr
} | LogToStderr sets whether to log exclusively to stderr, bypassing outputs | LogToStderr | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) output(s severity.Severity, logger *logWriter, buf *buffer.Buffer, depth int, file string, line int, alsoToStderr bool) {
var isLocked = true
l.mu.Lock()
defer func() {
if isLocked {
// Unlock before returning in case that it wasn't done already.
l.mu.Unlock()
}
}()
if l.traceLocation.isSet() {
if l.traceLocation.match(file, line) {
buf.Write(dbg.Stacks(false))
}
}
data := buf.Bytes()
if logger != nil {
if logger.writeKlogBuffer != nil {
logger.writeKlogBuffer(data)
} else {
if len(data) > 0 && data[len(data)-1] == '\n' {
data = data[:len(data)-1]
}
// TODO: set 'severity' and caller information as structured log info
// keysAndValues := []interface{}{"severity", severityName[s], "file", file, "line", line}
if s == severity.ErrorLog {
logger.WithCallDepth(depth+3).Error(nil, string(data))
} else {
logger.WithCallDepth(depth + 3).Info(string(data))
}
}
} else if l.toStderr {
os.Stderr.Write(data)
} else {
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
os.Stderr.Write(data)
}
if logging.logFile != "" {
// Since we are using a single log file, all of the items in l.file array
// will point to the same file, so just use one of them to write data.
if l.file[severity.InfoLog] == nil {
if err := l.createFiles(severity.InfoLog); err != nil {
os.Stderr.Write(data) // Make sure the message appears somewhere.
l.exit(err)
}
}
_, _ = l.file[severity.InfoLog].Write(data)
} else {
if l.file[s] == nil {
if err := l.createFiles(s); err != nil {
os.Stderr.Write(data) // Make sure the message appears somewhere.
l.exit(err)
}
}
if l.oneOutput {
_, _ = l.file[s].Write(data)
} else {
switch s {
case severity.FatalLog:
_, _ = l.file[severity.FatalLog].Write(data)
fallthrough
case severity.ErrorLog:
_, _ = l.file[severity.ErrorLog].Write(data)
fallthrough
case severity.WarningLog:
_, _ = l.file[severity.WarningLog].Write(data)
fallthrough
case severity.InfoLog:
_, _ = l.file[severity.InfoLog].Write(data)
}
}
}
}
if s == severity.FatalLog {
// If we got here via Exit rather than Fatal, print no stacks.
if atomic.LoadUint32(&fatalNoStacks) > 0 {
l.mu.Unlock()
isLocked = false
timeoutFlush(ExitFlushTimeout)
OsExit(1)
}
// Dump all goroutine stacks before exiting.
// First, make sure we see the trace for the current goroutine on standard error.
// If -logtostderr has been specified, the loop below will do that anyway
// as the first stack in the full dump.
if !l.toStderr {
os.Stderr.Write(dbg.Stacks(false))
}
// Write the stack trace for all goroutines to the files.
trace := dbg.Stacks(true)
logExitFunc = func(error) {} // If we get a write error, we'll still exit below.
for log := severity.FatalLog; log >= severity.InfoLog; log-- {
if f := l.file[log]; f != nil { // Can be nil if -logtostderr is set.
_, _ = f.Write(trace)
}
}
l.mu.Unlock()
isLocked = false
timeoutFlush(ExitFlushTimeout)
OsExit(255) // C++ uses -1, which is silly because it's anded with 255 anyway.
}
buffer.PutBuffer(buf)
if stats := severityStats[s]; stats != nil {
atomic.AddInt64(&stats.lines, 1)
atomic.AddInt64(&stats.bytes, int64(len(data)))
}
} | output writes the data to the log files and releases the buffer. | output | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func CalculateMaxSize() uint64 {
if logging.logFile != "" {
if logging.logFileMaxSizeMB == 0 {
// If logFileMaxSizeMB is zero, we don't have limitations on the log size.
return math.MaxUint64
}
// Flag logFileMaxSizeMB is in MB for user convenience.
return logging.logFileMaxSizeMB * 1024 * 1024
}
// If "log_file" flag is not specified, the target file (sb.file) will be cleaned up when reaches a fixed size.
return MaxSize
} | CalculateMaxSize returns the real max size in bytes after considering the default max size and the flag options. | CalculateMaxSize | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (sb *syncBuffer) rotateFile(now time.Time, startup bool) error {
if sb.file != nil {
sb.Flush()
sb.file.Close()
}
var err error
sb.file, _, err = create(severity.Name[sb.sev], now, startup)
if err != nil {
return err
}
if startup {
fileInfo, err := sb.file.Stat()
if err != nil {
return fmt.Errorf("file stat could not get fileinfo: %v", err)
}
// init file size
sb.nbytes = uint64(fileInfo.Size())
} else {
sb.nbytes = 0
}
sb.Writer = bufio.NewWriterSize(sb.file, bufferSize)
if sb.logger.skipLogHeaders {
return nil
}
// Write header.
var buf bytes.Buffer
fmt.Fprintf(&buf, "Log file created at: %s\n", now.Format("2006/01/02 15:04:05"))
fmt.Fprintf(&buf, "Running on machine: %s\n", host)
fmt.Fprintf(&buf, "Binary: Built with %s %s for %s/%s\n", runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH)
fmt.Fprintf(&buf, "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg\n")
n, err := sb.file.Write(buf.Bytes())
sb.nbytes += uint64(n)
return err
} | rotateFile closes the syncBuffer's file and starts a new one.
The startup argument indicates whether this is the initial startup of klog.
If startup is true, existing files are opened for appending instead of truncated. | rotateFile | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) createFiles(sev severity.Severity) error {
interval := l.flushInterval
if interval == 0 {
interval = flushInterval
}
l.flushD.run(interval)
now := time.Now()
// Files are created in decreasing severity order, so as soon as we find one
// has already been created, we can stop.
for s := sev; s >= severity.InfoLog && l.file[s] == nil; s-- {
sb := &syncBuffer{
logger: l,
sev: s,
maxbytes: CalculateMaxSize(),
}
if err := sb.rotateFile(now, true); err != nil {
return err
}
l.file[s] = sb
}
return nil
} | createFiles creates all the log files for severity from sev down to infoLog.
l.mu is held. | createFiles | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func newFlushDaemon(flush func(), tickClock clock.Clock) *flushDaemon {
if tickClock == nil {
tickClock = clock.RealClock{}
}
return &flushDaemon{
flush: flush,
clock: tickClock,
}
} | newFlushDaemon returns a new flushDaemon. If the passed clock is nil, a
clock.RealClock is used. | newFlushDaemon | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (f *flushDaemon) run(interval time.Duration) {
f.mu.Lock()
defer f.mu.Unlock()
if f.stopC != nil { // daemon already running
return
}
f.stopC = make(chan struct{}, 1)
f.stopDone = make(chan struct{}, 1)
ticker := f.clock.NewTicker(interval)
go func() {
defer ticker.Stop()
defer func() { f.stopDone <- struct{}{} }()
for {
select {
case <-ticker.C():
f.flush()
case <-f.stopC:
f.flush()
return
}
}
}()
} | run starts a goroutine that periodically calls the daemons flush function.
Calling run on an already running daemon will have no effect. | run | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (f *flushDaemon) stop() {
f.mu.Lock()
defer f.mu.Unlock()
if f.stopC == nil { // daemon not running
return
}
f.stopC <- struct{}{}
<-f.stopDone
f.stopC = nil
f.stopDone = nil
} | stop stops the running flushDaemon and waits until the daemon has shut down.
Calling stop on a daemon that isn't running will have no effect. | stop | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (f *flushDaemon) isRunning() bool {
f.mu.Lock()
defer f.mu.Unlock()
return f.stopC != nil
} | isRunning returns true if the flush daemon is running. | isRunning | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func StopFlushDaemon() {
logging.flushD.stop()
} | StopFlushDaemon stops the flush daemon, if running, and flushes once.
This prevents klog from leaking goroutines on shutdown. After stopping
the daemon, you can still manually flush buffers again by calling Flush(). | StopFlushDaemon | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func StartFlushDaemon(interval time.Duration) {
StopFlushDaemon()
logging.flushD.run(interval)
} | StartFlushDaemon ensures that the flush daemon runs with the given delay
between flush calls. If it is already running, it gets restarted. | StartFlushDaemon | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) lockAndFlushAll() {
l.mu.Lock()
l.flushAll()
l.mu.Unlock()
} | lockAndFlushAll is like flushAll but locks l.mu first. | lockAndFlushAll | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) flushAll() {
// Flush from fatal down, in case there's trouble flushing.
for s := severity.FatalLog; s >= severity.InfoLog; s-- {
file := l.file[s]
if file != nil {
_ = file.Flush() // ignore error
_ = file.Sync() // ignore error
}
}
if logging.loggerOptions.flush != nil {
logging.loggerOptions.flush()
}
} | flushAll flushes all the logs and attempts to "sync" their data to disk.
l.mu is held. | flushAll | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func CopyStandardLogTo(name string) {
sev, ok := severity.ByName(name)
if !ok {
panic(fmt.Sprintf("log.CopyStandardLogTo(%q): unrecognized severity name", name))
}
// Set a log format that captures the user's file and line:
// d.go:23: message
stdLog.SetFlags(stdLog.Lshortfile)
stdLog.SetOutput(logBridge(sev))
} | CopyStandardLogTo arranges for messages written to the Go "log" package's
default logs to also appear in the Google logs for the named and lower
severities. Subsequent changes to the standard log's default output location
or format may break this behavior.
Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not
recognized, CopyStandardLogTo panics. | CopyStandardLogTo | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func NewStandardLogger(name string) *stdLog.Logger {
sev, ok := severity.ByName(name)
if !ok {
panic(fmt.Sprintf("klog.NewStandardLogger(%q): unknown severity", name))
}
return stdLog.New(logBridge(sev), "", stdLog.Lshortfile)
} | NewStandardLogger returns a Logger that writes to the klog logs for the
named and lower severities.
Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not
recognized, NewStandardLogger panics. | NewStandardLogger | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (lb logBridge) Write(b []byte) (n int, err error) {
var (
file = "???"
line = 1
text string
)
// Split "d.go:23: message" into "d.go", "23", and "message".
if parts := bytes.SplitN(b, []byte{':'}, 3); len(parts) != 3 || len(parts[0]) < 1 || len(parts[2]) < 1 {
text = fmt.Sprintf("bad log format: %s", b)
} else {
file = string(parts[0])
text = string(parts[2][1:]) // skip leading space
line, err = strconv.Atoi(string(parts[1]))
if err != nil {
text = fmt.Sprintf("bad line number: %s", b)
line = 1
}
}
// printWithFileLine with alsoToStderr=true, so standard log messages
// always appear on standard error.
logging.printWithFileLine(severity.Severity(lb), logging.logger, logging.filter, file, line, true, text)
return len(b), nil
} | Write parses the standard logging line and passes its components to the
logger for severity(lb). | Write | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (l *loggingT) setV(pc uintptr) Level {
fn := runtime.FuncForPC(pc)
file, _ := fn.FileLine(pc)
// The file is something like /a/b/c/d.go. We want just the d.
file = strings.TrimSuffix(file, ".go")
if slash := strings.LastIndex(file, "/"); slash >= 0 {
file = file[slash+1:]
}
for _, filter := range l.vmodule.filter {
if filter.match(file) {
l.vmap[pc] = filter.level
return filter.level
}
}
l.vmap[pc] = 0
return 0
} | setV computes and remembers the V level for a given PC
when vmodule is enabled.
File pattern matching takes the basename of the file, stripped
of its .go suffix, and uses filepath.Match, which is a little more
general than the *? matching used in C++.
l.mu is held. | setV | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func V(level Level) Verbose {
return VDepth(1, level)
} | V reports whether verbosity at the call site is at least the requested level.
The returned value is a struct 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 klog.V(2).Enabled() { klog.Info("log this") }
or
klog.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. The V call will log if its level
is less than or equal to the value of the -v flag, or alternatively if its level is
less than or equal to the value of the -vmodule pattern matching the source file
containing the call. | V | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func VDepth(depth int, level Level) Verbose {
// 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 logging.verbosity.get() >= level {
return newVerbose(level, true)
}
// It's off globally but vmodule may still be set.
// Here is another cheap but safe test to see if vmodule is enabled.
if atomic.LoadInt32(&logging.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.
logging.mu.Lock()
defer logging.mu.Unlock()
if runtime.Callers(2+depth, logging.pcs[:]) == 0 {
return newVerbose(level, false)
}
// runtime.Callers returns "return PCs", but we want
// to look up the symbolic information for the call,
// so subtract 1 from the PC. runtime.CallersFrames
// would be cleaner, but allocates.
pc := logging.pcs[0] - 1
v, ok := logging.vmap[pc]
if !ok {
v = logging.setV(pc)
}
return newVerbose(level, v >= level)
}
return newVerbose(level, false)
} | VDepth is a variant of V that accepts a number of stack frames that will be
skipped when checking the -vmodule patterns. VDepth(0) is equivalent to
V(). | VDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) Enabled() bool {
return v.enabled
} | Enabled will return true if this log level is enabled, guarded by the value
of v.
See the documentation of V for usage. | Enabled | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) Info(args ...interface{}) {
if v.enabled {
logging.print(severity.InfoLog, v.logger, logging.filter, args...)
}
} | Info is equivalent to the global Info function, guarded by the value of v.
See the documentation of V for usage. | Info | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) InfoDepth(depth int, args ...interface{}) {
if v.enabled {
logging.printDepth(severity.InfoLog, v.logger, logging.filter, depth, args...)
}
} | InfoDepth is equivalent to the global InfoDepth function, guarded by the value of v.
See the documentation of V for usage. | InfoDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) Infoln(args ...interface{}) {
if v.enabled {
logging.println(severity.InfoLog, v.logger, logging.filter, args...)
}
} | Infoln is equivalent to the global Infoln function, guarded by the value of v.
See the documentation of V for usage. | Infoln | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) InfolnDepth(depth int, args ...interface{}) {
if v.enabled {
logging.printlnDepth(severity.InfoLog, v.logger, logging.filter, depth, args...)
}
} | InfolnDepth is equivalent to the global InfolnDepth function, guarded by the value of v.
See the documentation of V for usage. | InfolnDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) Infof(format string, args ...interface{}) {
if v.enabled {
logging.printf(severity.InfoLog, v.logger, logging.filter, format, args...)
}
} | Infof is equivalent to the global Infof function, guarded by the value of v.
See the documentation of V for usage. | Infof | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) InfofDepth(depth int, format string, args ...interface{}) {
if v.enabled {
logging.printfDepth(severity.InfoLog, v.logger, logging.filter, depth, format, args...)
}
} | InfofDepth is equivalent to the global InfofDepth function, guarded by the value of v.
See the documentation of V for usage. | InfofDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) InfoS(msg string, keysAndValues ...interface{}) {
if v.enabled {
logging.infoS(v.logger, logging.filter, 0, msg, keysAndValues...)
}
} | InfoS is equivalent to the global InfoS function, guarded by the value of v.
See the documentation of V for usage. | InfoS | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func InfoSDepth(depth int, msg string, keysAndValues ...interface{}) {
logging.infoS(logging.logger, logging.filter, depth, msg, keysAndValues...)
} | InfoSDepth acts as InfoS but uses depth to determine which call frame to log.
InfoSDepth(0, "msg") is the same as InfoS("msg"). | InfoSDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) InfoSDepth(depth int, msg string, keysAndValues ...interface{}) {
if v.enabled {
logging.infoS(v.logger, logging.filter, depth, msg, keysAndValues...)
}
} | InfoSDepth is equivalent to the global InfoSDepth function, guarded by the value of v.
See the documentation of V for usage. | InfoSDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) Error(err error, msg string, args ...interface{}) {
if v.enabled {
logging.errorS(err, v.logger, logging.filter, 0, msg, args...)
}
} | Deprecated: Use ErrorS instead. | Error | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func (v Verbose) ErrorS(err error, msg string, keysAndValues ...interface{}) {
if v.enabled {
logging.errorS(err, v.logger, logging.filter, 0, msg, keysAndValues...)
}
} | ErrorS is equivalent to the global Error function, guarded by the value of v.
See the documentation of V for usage. | ErrorS | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Info(args ...interface{}) {
logging.print(severity.InfoLog, logging.logger, logging.filter, args...)
} | Info logs to the INFO log.
Arguments are handled in the manner of fmt.Print; a newline is appended if missing. | Info | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func InfoDepth(depth int, args ...interface{}) {
logging.printDepth(severity.InfoLog, logging.logger, logging.filter, depth, args...)
} | InfoDepth acts as Info but uses depth to determine which call frame to log.
InfoDepth(0, "msg") is the same as Info("msg"). | InfoDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Infoln(args ...interface{}) {
logging.println(severity.InfoLog, logging.logger, logging.filter, args...)
} | Infoln logs to the INFO log.
Arguments are handled in the manner of fmt.Println; a newline is always appended. | Infoln | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func InfolnDepth(depth int, args ...interface{}) {
logging.printlnDepth(severity.InfoLog, logging.logger, logging.filter, depth, args...)
} | InfolnDepth acts as Infoln but uses depth to determine which call frame to log.
InfolnDepth(0, "msg") is the same as Infoln("msg"). | InfolnDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Infof(format string, args ...interface{}) {
logging.printf(severity.InfoLog, logging.logger, logging.filter, format, args...)
} | Infof logs to the INFO log.
Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. | Infof | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func InfofDepth(depth int, format string, args ...interface{}) {
logging.printfDepth(severity.InfoLog, logging.logger, logging.filter, depth, format, args...)
} | InfofDepth acts as Infof but uses depth to determine which call frame to log.
InfofDepth(0, "msg", args...) is the same as Infof("msg", args...). | InfofDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func InfoS(msg string, keysAndValues ...interface{}) {
logging.infoS(logging.logger, logging.filter, 0, msg, keysAndValues...)
} | InfoS structured logs to the INFO log.
The msg argument used to add constant description to the log line.
The key/value pairs would be join by "=" ; a newline is always appended.
Basic examples:
>> klog.InfoS("Pod status updated", "pod", "kubedns", "status", "ready")
output:
>> I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kubedns" status="ready" | InfoS | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Warning(args ...interface{}) {
logging.print(severity.WarningLog, logging.logger, logging.filter, args...)
} | Warning logs to the WARNING and INFO logs.
Arguments are handled in the manner of fmt.Print; a newline is appended if missing. | Warning | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func WarningDepth(depth int, args ...interface{}) {
logging.printDepth(severity.WarningLog, logging.logger, logging.filter, depth, args...)
} | WarningDepth acts as Warning but uses depth to determine which call frame to log.
WarningDepth(0, "msg") is the same as Warning("msg"). | WarningDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Warningln(args ...interface{}) {
logging.println(severity.WarningLog, logging.logger, logging.filter, args...)
} | Warningln logs to the WARNING and INFO logs.
Arguments are handled in the manner of fmt.Println; a newline is always appended. | Warningln | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func WarninglnDepth(depth int, args ...interface{}) {
logging.printlnDepth(severity.WarningLog, logging.logger, logging.filter, depth, args...)
} | WarninglnDepth acts as Warningln but uses depth to determine which call frame to log.
WarninglnDepth(0, "msg") is the same as Warningln("msg"). | WarninglnDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Warningf(format string, args ...interface{}) {
logging.printf(severity.WarningLog, logging.logger, logging.filter, format, args...)
} | Warningf logs to the WARNING and INFO logs.
Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. | Warningf | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func WarningfDepth(depth int, format string, args ...interface{}) {
logging.printfDepth(severity.WarningLog, logging.logger, logging.filter, depth, format, args...)
} | WarningfDepth acts as Warningf but uses depth to determine which call frame to log.
WarningfDepth(0, "msg", args...) is the same as Warningf("msg", args...). | WarningfDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Error(args ...interface{}) {
logging.print(severity.ErrorLog, logging.logger, logging.filter, args...)
} | Error logs to the ERROR, WARNING, and INFO logs.
Arguments are handled in the manner of fmt.Print; a newline is appended if missing. | Error | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func ErrorDepth(depth int, args ...interface{}) {
logging.printDepth(severity.ErrorLog, logging.logger, logging.filter, depth, args...)
} | ErrorDepth acts as Error but uses depth to determine which call frame to log.
ErrorDepth(0, "msg") is the same as Error("msg"). | ErrorDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Errorln(args ...interface{}) {
logging.println(severity.ErrorLog, logging.logger, logging.filter, args...)
} | Errorln logs to the ERROR, WARNING, and INFO logs.
Arguments are handled in the manner of fmt.Println; a newline is always appended. | Errorln | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func ErrorlnDepth(depth int, args ...interface{}) {
logging.printlnDepth(severity.ErrorLog, logging.logger, logging.filter, depth, args...)
} | ErrorlnDepth acts as Errorln but uses depth to determine which call frame to log.
ErrorlnDepth(0, "msg") is the same as Errorln("msg"). | ErrorlnDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Errorf(format string, args ...interface{}) {
logging.printf(severity.ErrorLog, logging.logger, logging.filter, format, args...)
} | Errorf logs to the ERROR, WARNING, and INFO logs.
Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. | Errorf | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func ErrorfDepth(depth int, format string, args ...interface{}) {
logging.printfDepth(severity.ErrorLog, logging.logger, logging.filter, depth, format, args...)
} | ErrorfDepth acts as Errorf but uses depth to determine which call frame to log.
ErrorfDepth(0, "msg", args...) is the same as Errorf("msg", args...). | ErrorfDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func ErrorS(err error, msg string, keysAndValues ...interface{}) {
logging.errorS(err, logging.logger, logging.filter, 0, msg, keysAndValues...)
} | ErrorS structured logs to the ERROR, WARNING, and INFO logs.
the err argument used as "err" field of log line.
The msg argument used to add constant description to the log line.
The key/value pairs would be join by "=" ; a newline is always appended.
Basic examples:
>> klog.ErrorS(err, "Failed to update pod status")
output:
>> E1025 00:15:15.525108 1 controller_utils.go:114] "Failed to update pod status" err="timeout" | ErrorS | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func ErrorSDepth(depth int, err error, msg string, keysAndValues ...interface{}) {
logging.errorS(err, logging.logger, logging.filter, depth, msg, keysAndValues...)
} | ErrorSDepth acts as ErrorS but uses depth to determine which call frame to log.
ErrorSDepth(0, "msg") is the same as ErrorS("msg"). | ErrorSDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Fatal(args ...interface{}) {
logging.print(severity.FatalLog, logging.logger, logging.filter, args...)
} | Fatal logs to the FATAL, ERROR, WARNING, and INFO logs,
prints stack trace(s), then calls OsExit(255).
Stderr only receives a dump of the current goroutine's stack trace. Log files,
if there are any, receive a dump of the stack traces in all goroutines.
Callers who want more control over handling of fatal events may instead use a
combination of different functions:
- some info or error logging function, optionally with a stack trace
value generated by github.com/go-logr/lib/dbg.Backtrace
- Flush to flush pending log data
- panic, os.Exit or returning to the caller with an error
Arguments are handled in the manner of fmt.Print; a newline is appended if missing. | Fatal | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func FatalDepth(depth int, args ...interface{}) {
logging.printDepth(severity.FatalLog, logging.logger, logging.filter, depth, args...)
} | FatalDepth acts as Fatal but uses depth to determine which call frame to log.
FatalDepth(0, "msg") is the same as Fatal("msg"). | FatalDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func Fatalln(args ...interface{}) {
logging.println(severity.FatalLog, logging.logger, logging.filter, args...)
} | Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs,
including a stack trace of all running goroutines, then calls OsExit(255).
Arguments are handled in the manner of fmt.Println; a newline is always appended. | Fatalln | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
func FatallnDepth(depth int, args ...interface{}) {
logging.printlnDepth(severity.FatalLog, logging.logger, logging.filter, depth, args...)
} | FatallnDepth acts as Fatalln but uses depth to determine which call frame to log.
FatallnDepth(0, "msg") is the same as Fatalln("msg"). | FatallnDepth | go | k8snetworkplumbingwg/multus-cni | vendor/k8s.io/klog/v2/klog.go | https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/v2/klog.go | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.