log

package module
v0.60.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 164

Documentation

Overview

Package log implements logging for the datadog agent. It wraps seelog, and supports logging to multiple destinations, buffering messages logged before setup, and scrubbing secrets from log messages.

Compatibility

This module is exported and can be used outside of the datadog-agent repository, but is not designed as a general-purpose logging system. Its API may change incompatibly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildLogEntry added in v0.49.0

func BuildLogEntry(v ...interface{}) string

BuildLogEntry concatenates all inputs with spaces

func ChangeLogLevel

func ChangeLogLevel(li seelog.LoggerInterface, level string) error

ChangeLogLevel changes the current log level, valid levels are trace, debug, info, warn, error, critical and off, it requires a new seelog logger because an existing one cannot be updated

func Critical

func Critical(v ...interface{}) error

Critical logs at the critical level and returns an error containing the formated log message

func CriticalFunc added in v0.40.0

func CriticalFunc(logFunc func() string)

CriticalFunc calls and logs the result of 'logFunc' if and only if Critical (or more verbose) logs are enabled

func CriticalStackDepth

func CriticalStackDepth(depth int, v ...interface{}) error

CriticalStackDepth logs at the critical level and the current stack depth plus the additional given one and returns an error containing the formated log message

func Criticalc added in v0.30.0

func Criticalc(message string, context ...interface{}) error

Criticalc logs at the critical level with context and returns an error containing the formated log message

func CriticalcStackDepth added in v0.32.0

func CriticalcStackDepth(message string, depth int, context ...interface{}) error

CriticalcStackDepth logs at the critical level with context and the current stack depth plus the additional given one and returns an error containing the formated log message

func Criticalf

func Criticalf(format string, params ...interface{}) error

Criticalf logs with format at the critical level and returns an error containing the formated log message

func CriticalfStackDepth added in v0.48.0

func CriticalfStackDepth(depth int, format string, params ...interface{}) error

CriticalfStackDepth logs with format at the critical level and the current stack depth plus the given depth

func Debug

func Debug(v ...interface{})

Debug logs at the debug level

func DebugFunc added in v0.40.0

func DebugFunc(logFunc func() string)

DebugFunc calls and logs the result of 'logFunc' if and only if Debug (or more verbose) logs are enabled

func DebugServerless added in v0.35.0

func DebugServerless(_ ...interface{})

DebugServerless logs at the debug level only in a serverless context no-op in a non serverless context

func DebugStackDepth added in v0.30.0

func DebugStackDepth(depth int, v ...interface{})

DebugStackDepth logs at the debug level and the current stack depth plus the additional given one and returns an error containing the formated log message

func Debugc

func Debugc(message string, context ...interface{})

Debugc logs at the debug level with context

func DebugcStackDepth added in v0.32.0

func DebugcStackDepth(message string, depth int, context ...interface{})

DebugcStackDepth logs at the debug level with context and the current stack depth plus the additional given one

func Debugf

func Debugf(format string, params ...interface{})

Debugf logs with format at the debug level

func DebugfServerless added in v0.35.0

func DebugfServerless(_ string, _ ...interface{})

DebugfServerless logs with format at the debug level only in a serverless context no-op in a non serverless context

func DebugfStackDepth added in v0.48.0

func DebugfStackDepth(depth int, format string, params ...interface{})

DebugfStackDepth logs with format at the debug level and the current stack depth plus the given depth

func Error

func Error(v ...interface{}) error

Error logs at the error level and returns an error containing the formated log message

func ErrorFunc added in v0.40.0

func ErrorFunc(logFunc func() string)

ErrorFunc calls and logs the result of 'logFunc' if and only if Error (or more verbose) logs are enabled

func ErrorStackDepth

func ErrorStackDepth(depth int, v ...interface{}) error

ErrorStackDepth logs at the error level and the current stack depth plus the additional given one and returns an error containing the formated log message

func Errorc added in v0.30.0

func Errorc(message string, context ...interface{}) error

Errorc logs at the error level with context and returns an error containing the formated log message

func ErrorcStackDepth added in v0.32.0

func ErrorcStackDepth(message string, depth int, context ...interface{}) error

ErrorcStackDepth logs at the error level with context and the current stack depth plus the additional given one and returns an error containing the formated log message

func Errorf

func Errorf(format string, params ...interface{}) error

Errorf logs with format at the error level and returns an error containing the formated log message

func ErrorfStackDepth added in v0.48.0

func ErrorfStackDepth(depth int, format string, params ...interface{}) error

ErrorfStackDepth logs with format at the error level and the current stack depth plus the given depth

func ExtractPodmanRootDirFromDBPath added in v0.59.0

func ExtractPodmanRootDirFromDBPath(podmanDBPath string) string

ExtractPodmanRootDirFromDBPath extracts the podman base path for the containers directory based on the user-provided `podman_db_path`.

func Flush

func Flush()

Flush flushes the underlying inner log

func GetLogLevel

func GetLogLevel() (seelog.LogLevel, error)

GetLogLevel returns a seelog native representation of the current log level

func Info

func Info(v ...interface{})

Info logs at the info level

func InfoFunc added in v0.40.0

func InfoFunc(logFunc func() string)

InfoFunc calls and logs the result of 'logFunc' if and only if Info (or more verbose) logs are enabled

func InfoStackDepth

func InfoStackDepth(depth int, v ...interface{})

InfoStackDepth logs at the info level and the current stack depth plus the additional given one

func Infoc

func Infoc(message string, context ...interface{})

Infoc logs at the info level with context

func InfocStackDepth added in v0.32.0

func InfocStackDepth(message string, depth int, context ...interface{})

InfocStackDepth logs at the info level with context and the current stack depth plus the additional given one

func Infof

func Infof(format string, params ...interface{})

Infof logs with format at the info level

func InfofStackDepth added in v0.48.0

func InfofStackDepth(depth int, format string, params ...interface{})

InfofStackDepth logs with format at the info level and the current stack depth plus the given depth

func JMXError

func JMXError(v ...interface{}) error

JMXError Logs for JMX check

func JMXInfo

func JMXInfo(v ...interface{})

JMXInfo Logs

func RegisterAdditionalLogger

func RegisterAdditionalLogger(n string, li seelog.LoggerInterface) error

RegisterAdditionalLogger registers an additional logger for logging

func ReplaceLogger

func ReplaceLogger(li seelog.LoggerInterface) seelog.LoggerInterface

ReplaceLogger allows replacing the internal logger, returns old logger

func SetupJMXLogger

func SetupJMXLogger(i seelog.LoggerInterface, level string)

SetupJMXLogger setup JMXfetch specific logger

func SetupLogger

func SetupLogger(i seelog.LoggerInterface, level string)

SetupLogger setup agent wide logger

func ShouldLog added in v0.32.0

func ShouldLog(lvl seelog.LogLevel) bool

ShouldLog returns whether a given log level should be logged by the default logger

func Trace

func Trace(v ...interface{})

Trace logs at the trace level

func TraceFunc added in v0.40.0

func TraceFunc(logFunc func() string)

TraceFunc calls and logs the result of 'logFunc' if and only if Trace (or more verbose) logs are enabled

func TraceStackDepth added in v0.30.0

func TraceStackDepth(depth int, v ...interface{})

TraceStackDepth logs at the trace level and the current stack depth plus the additional given one and returns an error containing the formated log message

func Tracec

func Tracec(message string, context ...interface{})

Tracec logs at the trace level with context

func TracecStackDepth added in v0.32.0

func TracecStackDepth(message string, depth int, context ...interface{})

TracecStackDepth logs at the trace level with context and the current stack depth plus the additional given one

func Tracef

func Tracef(format string, params ...interface{})

Tracef logs with format at the trace level

func TracefStackDepth added in v0.48.0

func TracefStackDepth(depth int, format string, params ...interface{})

TracefStackDepth logs with format at the trace level and the current stack depth plus the given depth

func ValidateLogLevel added in v0.57.0

func ValidateLogLevel(logLevel string) (string, error)

ValidateLogLevel validates the given log level and returns the corresponding Seelog log level. If the log level is "warning", it is converted to "warn" to handle a common gotcha when used with agent5. If the log level is not recognized, an error is returned.

func Warn

func Warn(v ...interface{}) error

Warn logs at the warn level and returns an error containing the formated log message

func WarnFunc added in v0.40.0

func WarnFunc(logFunc func() string)

WarnFunc calls and logs the result of 'logFunc' if and only if Warn (or more verbose) logs are enabled

func WarnStackDepth

func WarnStackDepth(depth int, v ...interface{}) error

WarnStackDepth logs at the warn level and the current stack depth plus the additional given one and returns an error containing the formated log message

func Warnc added in v0.30.0

func Warnc(message string, context ...interface{}) error

Warnc logs at the warn level with context and returns an error containing the formated log message

func WarncStackDepth added in v0.32.0

func WarncStackDepth(message string, depth int, context ...interface{}) error

WarncStackDepth logs at the warn level with context and the current stack depth plus the additional given one and returns an error containing the formated log message

func Warnf

func Warnf(format string, params ...interface{}) error

Warnf logs with format at the warn level and returns an error containing the formated log message

func WarnfStackDepth added in v0.48.0

func WarnfStackDepth(depth int, format string, params ...interface{}) error

WarnfStackDepth logs with format at the warn level and the current stack depth plus the given depth

Types

type DatadogLogger

type DatadogLogger struct {
	// contains filtered or unexported fields
}

DatadogLogger wrapper structure for seelog

type KlogRedirectLogger added in v0.44.0

type KlogRedirectLogger struct {
	// contains filtered or unexported fields
}

KlogRedirectLogger is used to redirect klog logs to datadog logs. klog is client-go's logger, logging to STDERR by default, which makes all severities into ERROR, along with the formatting just being off. To make the conversion, we set a KlogRedirectLogger as klog's output, and parse the severity and log message out of every log line. NOTE: on klog v2 this parsing is no longer necessary, as it allows us to use kSetLogger() instead of kSetOutputBySeverity(). unfortunately we still have some dependencies stuck on v1, so we keep the parsing.

func NewKlogRedirectLogger added in v0.44.0

func NewKlogRedirectLogger(stackDepth int) KlogRedirectLogger

NewKlogRedirectLogger creates a new KlogRedirectLogger with provided stack depth

func (KlogRedirectLogger) Write added in v0.44.0

func (l KlogRedirectLogger) Write(b []byte) (int, error)

type Limit added in v0.53.0

type Limit struct {
	// contains filtered or unexported fields
}

Limit is a utility that can be used to avoid logging noisily

func NewLogLimit added in v0.53.0

func NewLogLimit(n int, interval time.Duration) *Limit

NewLogLimit creates a Limit where shouldLog will return true the first N times it is called, and will return true once every interval thereafter.

func (*Limit) Close added in v0.53.0

func (l *Limit) Close()

Close will stop the underlying ticker

func (*Limit) ShouldLog added in v0.53.0

func (l *Limit) ShouldLog() bool

ShouldLog returns true if the caller should log

type Wrapper added in v0.57.0

type Wrapper struct {
	// contains filtered or unexported fields
}

Wrapper wraps all the logger function on a struct. This is meant to be used by the comp/core/log component to expose the logger functionnality to components. This should only be use by the log component.

func NewWrapper added in v0.57.0

func NewWrapper(stackDepth int) *Wrapper

NewWrapper returns a new Wrapper. This should only be use by the log component.

func (*Wrapper) Critical added in v0.57.0

func (l *Wrapper) Critical(v ...interface{}) error

Critical implements Component#Critical.

func (*Wrapper) Criticalf added in v0.57.0

func (l *Wrapper) Criticalf(format string, params ...interface{}) error

Criticalf implements Component#Criticalf.

func (*Wrapper) Debug added in v0.57.0

func (l *Wrapper) Debug(v ...interface{})

Debug implements Component#Debug.

func (*Wrapper) Debugf added in v0.57.0

func (l *Wrapper) Debugf(format string, params ...interface{})

Debugf implements Component#Debugf.

func (*Wrapper) Error added in v0.57.0

func (l *Wrapper) Error(v ...interface{}) error

Error implements Component#Error.

func (*Wrapper) Errorf added in v0.57.0

func (l *Wrapper) Errorf(format string, params ...interface{}) error

Errorf implements Component#Errorf.

func (*Wrapper) Flush added in v0.57.0

func (l *Wrapper) Flush()

Flush implements Component#Flush.

func (*Wrapper) Info added in v0.57.0

func (l *Wrapper) Info(v ...interface{})

Info implements Component#Info.

func (*Wrapper) Infof added in v0.57.0

func (l *Wrapper) Infof(format string, params ...interface{})

Infof implements Component#Infof.

func (*Wrapper) Trace added in v0.57.0

func (l *Wrapper) Trace(v ...interface{})

Trace implements Component#Trace.

func (*Wrapper) Tracef added in v0.57.0

func (l *Wrapper) Tracef(format string, params ...interface{})

Tracef implements Component#Tracef.

func (*Wrapper) Warn added in v0.57.0

func (l *Wrapper) Warn(v ...interface{}) error

Warn implements Component#Warn.

func (*Wrapper) Warnf added in v0.57.0

func (l *Wrapper) Warnf(format string, params ...interface{}) error

Warnf implements Component#Warnf.

Directories

Path Synopsis
setup module
Package log wraps the zap logger
Package log wraps the zap logger

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL