logimpl

package
v0.52.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package logimpl implements a component to handle logging internal to the agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module() fxutil.Module

Module defines the fx options for this component.

func NewLogger

func NewLogger(lc fx.Lifecycle, params Params, config config.LogConfig) (log.Component, error)

NewLogger creates a log.Component using the provided config.LogConfig

func NewTemporaryLoggerWithoutInit

func NewTemporaryLoggerWithoutInit() log.Component

NewTemporaryLoggerWithoutInit returns a logger component instance. It assumes the logger has already been initialized beforehand.

This function should be used when all these conditions are true: - You write or update code which uses a lot of logging. - You want the code to be components ready. - logger.Component cannot be injected.

It should not be used when: - You add few logging functions. - When the instance of logger.Component is reachable in less than 5 stack frames. - It doesn't make the migration to log.Component easier.

func NewTraceLogger

func NewTraceLogger(lc fx.Lifecycle, params Params, config config.LogConfig, telemetryCollector telemetry.TelemetryCollector) (log.Component, error)

NewTraceLogger creates a pkglog.Component using the provided config.LogConfig

func TraceModule

func TraceModule() fxutil.Module

TraceModule defines the fx options for this component in its Trace variant.

TODO(components): move this comp/trace; that component shall implement the

log.Component interface.

Types

type Params

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

Params defines the parameters for this log component.

Logs-related parameters are implemented as unexported fields containing callbacks. These fields can be set with the `LogXxx()` methods, which return the updated LogParams. One of `logimpl.ForOneShot` or `logimpl.ForDaemon` must be called.

func ForDaemon

func ForDaemon(loggerName, logFileConfig, defaultLogFile string) Params

ForDaemon sets up logging parameters for a daemon app.

The log level is set based on the `log_level` config parameter.

The log file is set based on the logFileConfig config parameter, or disabled if `disable_file_logging` is set.

On platforms which support it, syslog is enabled if `log_to_syslog` is set, using `syslog_uri` or defaulting to "unixgram:///dev/log" if that is empty. The `syslog_rfc` config parameter determines whether this produces 5424-compliant output.

Console logging is enabled if `log_to_console` is set. Lots are formatted as JSON if `log_format_json` is set.

func ForOneShot

func ForOneShot(loggerName, level string, overrideFromEnv bool) Params

ForOneShot sets up logging parameters for a one-shot app.

If overrideFromEnv is set, then DD_LOG_LEVEL will override the given level.

Otherwise, file logging is disabled, syslog is disabled, console logging is enabled, and JSON formatting is disabled.

func (Params) LogFileFn

func (params Params) LogFileFn(c configGetter) string

LogFileFn returns the log file

func (Params) LogLevelFn

func (params Params) LogLevelFn(c configGetter) string

LogLevelFn returns the log level

func (*Params) LogToConsole

func (params *Params) LogToConsole(logToConsole bool)

LogToConsole modifies the parameters to toggle logging to console

func (*Params) LogToFile

func (params *Params) LogToFile(logFile string)

LogToFile modifies the parameters to set the destination log file, overriding any previous logfile parameter.

func (Params) LoggerName

func (params Params) LoggerName() string

LoggerName is the name that appears in the logfile

Jump to

Keyboard shortcuts

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