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 ¶
- func BuildLogEntry(v ...interface{}) string
- func ChangeLogLevel(li seelog.LoggerInterface, level string) error
- func Critical(v ...interface{}) error
- func CriticalFunc(logFunc func() string)
- func CriticalStackDepth(depth int, v ...interface{}) error
- func Criticalc(message string, context ...interface{}) error
- func CriticalcStackDepth(message string, depth int, context ...interface{}) error
- func Criticalf(format string, params ...interface{}) error
- func CriticalfStackDepth(depth int, format string, params ...interface{}) error
- func Debug(v ...interface{})
- func DebugFunc(logFunc func() string)
- func DebugServerless(_ ...interface{})
- func DebugStackDepth(depth int, v ...interface{})
- func Debugc(message string, context ...interface{})
- func DebugcStackDepth(message string, depth int, context ...interface{})
- func Debugf(format string, params ...interface{})
- func DebugfServerless(_ string, _ ...interface{})
- func DebugfStackDepth(depth int, format string, params ...interface{})
- func Error(v ...interface{}) error
- func ErrorFunc(logFunc func() string)
- func ErrorStackDepth(depth int, v ...interface{}) error
- func Errorc(message string, context ...interface{}) error
- func ErrorcStackDepth(message string, depth int, context ...interface{}) error
- func Errorf(format string, params ...interface{}) error
- func ErrorfStackDepth(depth int, format string, params ...interface{}) error
- func ExtractPodmanRootDirFromDBPath(podmanDBPath string) string
- func Flush()
- func GetLogLevel() (seelog.LogLevel, error)
- func Info(v ...interface{})
- func InfoFunc(logFunc func() string)
- func InfoStackDepth(depth int, v ...interface{})
- func Infoc(message string, context ...interface{})
- func InfocStackDepth(message string, depth int, context ...interface{})
- func Infof(format string, params ...interface{})
- func InfofStackDepth(depth int, format string, params ...interface{})
- func JMXError(v ...interface{}) error
- func JMXInfo(v ...interface{})
- func RegisterAdditionalLogger(n string, li seelog.LoggerInterface) error
- func ReplaceLogger(li seelog.LoggerInterface) seelog.LoggerInterface
- func SetupJMXLogger(i seelog.LoggerInterface, level string)
- func SetupLogger(i seelog.LoggerInterface, level string)
- func ShouldLog(lvl seelog.LogLevel) bool
- func Trace(v ...interface{})
- func TraceFunc(logFunc func() string)
- func TraceStackDepth(depth int, v ...interface{})
- func Tracec(message string, context ...interface{})
- func TracecStackDepth(message string, depth int, context ...interface{})
- func Tracef(format string, params ...interface{})
- func TracefStackDepth(depth int, format string, params ...interface{})
- func ValidateLogLevel(logLevel string) (string, error)
- func Warn(v ...interface{}) error
- func WarnFunc(logFunc func() string)
- func WarnStackDepth(depth int, v ...interface{}) error
- func Warnc(message string, context ...interface{}) error
- func WarncStackDepth(message string, depth int, context ...interface{}) error
- func Warnf(format string, params ...interface{}) error
- func WarnfStackDepth(depth int, format string, params ...interface{}) error
- type DatadogLogger
- type KlogRedirectLogger
- type Limit
- type Wrapper
- func (l *Wrapper) Critical(v ...interface{}) error
- func (l *Wrapper) Criticalf(format string, params ...interface{}) error
- func (l *Wrapper) Debug(v ...interface{})
- func (l *Wrapper) Debugf(format string, params ...interface{})
- func (l *Wrapper) Error(v ...interface{}) error
- func (l *Wrapper) Errorf(format string, params ...interface{}) error
- func (l *Wrapper) Flush()
- func (l *Wrapper) Info(v ...interface{})
- func (l *Wrapper) Infof(format string, params ...interface{})
- func (l *Wrapper) Trace(v ...interface{})
- func (l *Wrapper) Tracef(format string, params ...interface{})
- func (l *Wrapper) Warn(v ...interface{}) error
- func (l *Wrapper) Warnf(format string, params ...interface{}) error
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 ¶
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
Criticalc logs at the critical level with context and returns an error containing the formated log message
func CriticalcStackDepth ¶ added in v0.32.0
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 ¶
Criticalf logs with format at the critical level and returns an error containing the formated log message
func CriticalfStackDepth ¶ added in v0.48.0
CriticalfStackDepth logs with format at the critical level and the current stack depth plus the given depth
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
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
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 ¶
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
Errorc logs at the error level with context and returns an error containing the formated log message
func ErrorcStackDepth ¶ added in v0.32.0
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 ¶
Errorf logs with format at the error level and returns an error containing the formated log message
func ErrorfStackDepth ¶ added in v0.48.0
ErrorfStackDepth logs with format at the error level and the current stack depth plus the given depth
func ExtractPodmanRootDirFromDBPath ¶ added in v0.59.0
ExtractPodmanRootDirFromDBPath extracts the podman base path for the containers directory based on the user-provided `podman_db_path`.
func GetLogLevel ¶
GetLogLevel returns a seelog native representation of the current log 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
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
InfofStackDepth logs with format at the info level and the current stack depth plus the given depth
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
ShouldLog returns whether a given log level should be logged by the default logger
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
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
TracefStackDepth logs with format at the trace level and the current stack depth plus the given depth
func ValidateLogLevel ¶ added in v0.57.0
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 ¶
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
Warnc logs at the warn level with context and returns an error containing the formated log message
func WarncStackDepth ¶ added in v0.32.0
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 ¶
Warnf logs with format at the warn level and returns an error containing the formated log message
func WarnfStackDepth ¶ added in v0.48.0
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
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
NewLogLimit creates a Limit where shouldLog will return true the first N times it is called, and will return true once every interval thereafter.
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
NewWrapper returns a new Wrapper. This should only be use by the log component.
func (*Wrapper) Debug ¶ added in v0.57.0
func (l *Wrapper) Debug(v ...interface{})
Debug implements Component#Debug.
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) Trace ¶ added in v0.57.0
func (l *Wrapper) Trace(v ...interface{})
Trace implements Component#Trace.