Documentation
¶
Overview ¶
Package logs contain methods to configure Agent logs
Index ¶
- func BuildJMXLogger(logFile, syslogURI string, syslogRFC, logToConsole, jsonFormat bool, ...) (log.LoggerInterface, error)
- func GetSyslogURI(cfg pkgconfigmodel.Reader) string
- func NewLogWriter(additionalDepth int, logLevel log.LogLevel) (io.Writer, error)
- func NewTLSHandshakeErrorWriter(additionalDepth int, logLevel log.LogLevel) (io.Writer, error)
- func RegisterErrortrackingBouncer(b *errortracking.Bouncer)
- func RegisterErrortrackingSubmitter(s errortracking.Submitter)
- func SetupDogstatsdLogger(logFile string, cfg pkgconfigmodel.Reader) (log.LoggerInterface, error)
- func SetupLogger(loggerName LoggerName, strLogLevel, logFile, syslogURI string, ...) error
- type LoggerName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildJMXLogger ¶ added in v0.71.0
func BuildJMXLogger(logFile, syslogURI string, syslogRFC, logToConsole, jsonFormat bool, cfg pkgconfigmodel.Reader) (log.LoggerInterface, error)
BuildJMXLogger returns a logger with JMX logger name and log level if a non empty logFile is provided, it will also log to the file a non empty syslogURI will enable syslog, and format them following RFC 5424 if specified you can also specify to log to the console and in JSON format
func GetSyslogURI ¶
func GetSyslogURI(cfg pkgconfigmodel.Reader) string
GetSyslogURI returns the configured/default syslog uri. Returns an empty string when syslog is disabled.
func NewLogWriter ¶
NewLogWriter returns a logWriter set with given logLevel. Returns an error if logLevel is unknown/not set.
func NewTLSHandshakeErrorWriter ¶
NewTLSHandshakeErrorWriter is a wrapper function which creates a new logWriter.
func RegisterErrortrackingBouncer ¶ added in v0.82.0
func RegisterErrortrackingBouncer(b *errortracking.Bouncer)
RegisterErrortrackingBouncer installs b as the per-PC dedup Bouncer for the errortracking branch of every slog chain built via buildSlogLogger. Passing nil clears the registration so subsequent records bypass dedup. The Fx graph in the run command's installErrortrackingHandler registers the agenttelemetry component's Bouncer here at startup, alongside the Submitter.
func RegisterErrortrackingSubmitter ¶ added in v0.82.0
func RegisterErrortrackingSubmitter(s errortracking.Submitter)
RegisterErrortrackingSubmitter installs s as the destination for error records routed through the errortracking branch of every slog chain built via buildSlogLogger. Passing nil clears the registration so the branch becomes a no-op again - tests use this to clean up between cases.
This is a setter rather than a constructor argument because SetupLogger is invoked from many call-sites (most without Fx access) and we do not want to thread a Submitter through every one. The Fx graph in the run command resolves the agenttelemetry component and calls RegisterErrortrackingSubmitter exactly once during startup. The errortracking.Handler atomic-loads the slot on every record, so there is no slow-path mutex on the logger hot path.
func SetupDogstatsdLogger ¶
func SetupDogstatsdLogger(logFile string, cfg pkgconfigmodel.Reader) (log.LoggerInterface, error)
SetupDogstatsdLogger returns a logger with dogstatsd logger name and log level if a non empty logFile is provided, it will also log to the file
func SetupLogger ¶
func SetupLogger(loggerName LoggerName, strLogLevel, logFile, syslogURI string, syslogRFC, logToConsole, jsonFormat bool, cfg pkgconfigmodel.Reader) error
SetupLogger sets up a logger with the specified logger name and log level if a non empty logFile is provided, it will also log to the file a non empty syslogURI will enable syslog, and format them following RFC 5424 if specified you can also specify to log to the console and in JSON format
Types ¶
type LoggerName ¶
type LoggerName string
LoggerName specifies the name of an instantiated logger.
const ( CoreLoggerName LoggerName = "CORE" JMXLoggerName LoggerName = "JMXFETCH" DogstatsDLoggerName LoggerName = "DOGSTATSD" )
Constant values for LoggerName.