log

package
v1.1.105 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 17 Imported by: 41

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLogConfig = configerrors.Newf(1410, "logging configuration error - %v does not meet criteria (%v)")
)

Log Config Errors

Functions

func ConvertMaxSize added in v1.1.89

func ConvertMaxSize(maxSize int) int

ConvertMaxSize - takes max size in bytes and returns in megabytes for the rotate file hook

func Debug

func Debug(args ...interface{})

Debug -

func DebugRedacted

func DebugRedacted(redactedFields []string, args ...interface{})

DebugRedacted Redacted log for debugging

func Debugf

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

Debugf -

func DeprecationWarningDoc

func DeprecationWarningDoc(old string, docRef string)

DeprecationWarningDoc - log a deprecation warning with the old and replaced usage

func DeprecationWarningReplace

func DeprecationWarningReplace(old string, new string)

DeprecationWarningReplace - log a deprecation warning with the old and replaced usage

func Error

func Error(args ...interface{})

Error -

func ErrorRedacted

func ErrorRedacted(redactedFields []string, args ...interface{})

ErrorRedacted Redacted log for errors

func Errorf

func Errorf(format string, args ...interface{})

Errorf -

func Get

func Get() *logrus.Logger

Get returns the global logger

func GetLevel

func GetLevel() logrus.Level

GetLevel -

func GetMetricLogger added in v1.1.80

func GetMetricLogger() *logrus.Logger

GetMetricLogger returns the metric logger

func GetUsageLogger added in v1.1.83

func GetUsageLogger() *logrus.Logger

func Info

func Info(args ...interface{})

Info -

func InfoRedacted

func InfoRedacted(redactedFields []string, args ...interface{})

InfoRedacted Redacted log for information

func Infof

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

Infof -

func IsHTTPLogTraceEnabled

func IsHTTPLogTraceEnabled() bool

IsHTTPLogTraceEnabled -

func NewRequestWithTraceContext

func NewRequestWithTraceContext(id string, req *http.Request) *http.Request

NewRequestWithTraceContext - New request trace context

func ObscureArguments

func ObscureArguments(redactedFields []string, args ...interface{}) []interface{}

ObscureArguments obscure/mask/redact values for a set of trailing arguments

func RegisterContextField added in v1.1.44

func RegisterContextField(ctxFields ...ContextField)

func SetIsLogP

func SetIsLogP()

SetIsLogP -

func SetLevel

func SetLevel(level logrus.Level)

SetLevel -

func Trace

func Trace(args ...interface{})

Trace -

func TraceRedacted

func TraceRedacted(redactedFields []string, args ...interface{})

TraceRedacted Redacted log for traces

func Tracef

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

Tracef -

func UnsetIsLogP

func UnsetIsLogP()

UnsetIsLogP -

func Warn

func Warn(args ...interface{})

Warn -

func Warnf

func Warnf(format string, args ...interface{})

Warnf -

Types

type ContextField added in v1.1.44

type ContextField string
const (
	KindCtx ContextField = "kind"
	NameCtx ContextField = "name"
)

type FieldLogger

type FieldLogger interface {
	StdLogger
	WithField(key string, value interface{}) FieldLogger
	WithFields(fields logrus.Fields) FieldLogger
	WithError(err error) FieldLogger
	WithComponent(componentName string) FieldLogger
	WithPackage(packageName string) FieldLogger
}

FieldLogger Wraps the StdLogger, and provides logrus methods for logging with fields. Intended to mimic the logrus.FieldLogger interface, but with our own interface and implementation.

func NewFieldLogger

func NewFieldLogger() FieldLogger

NewFieldLogger returns a FieldLogger for standard logging, and logp logging.

func NewFieldLoggerEntry added in v1.1.80

func NewFieldLoggerEntry(l *logrus.Logger, isLogP bool) FieldLogger

NewFieldLoggerEntry returns a FieldLogger for standard logging, and logp logging.

func NewLoggerFromContext added in v1.1.44

func NewLoggerFromContext(ctx context.Context) FieldLogger

NewLoggerFromContext returns a FieldLogger for standard logging, and logp logging.

func NewMetricFieldLogger added in v1.1.80

func NewMetricFieldLogger() FieldLogger

NewFieldLogger returns a FieldLogger for standard logging, and logp logging.

func NewUsageFieldLogger added in v1.1.83

func NewUsageFieldLogger() FieldLogger

NewFieldLogger returns a FieldLogger for standard logging, and logp logging.

func UpdateLoggerWithContext added in v1.1.44

func UpdateLoggerWithContext(ctx context.Context, logger FieldLogger) FieldLogger

UpdateLoggerWithContext returns a FieldLogger for standard logging, and logp logging.

type LoggerConfig

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

LoggerConfig - is a builder used to setup the logging for an agent

var GlobalLoggerConfig LoggerConfig

GlobalLoggerConfig - is the default config of the logger

func (*LoggerConfig) Apply

func (b *LoggerConfig) Apply() error

Apply - applies the config changes to the logger

func (*LoggerConfig) Filename

func (b *LoggerConfig) Filename(filename string) *LoggerConfig

Filename -

func (*LoggerConfig) Format

func (b *LoggerConfig) Format(format string) *LoggerConfig

Format - sets the logger formatt

func (*LoggerConfig) GetLevel

func (b *LoggerConfig) GetLevel() string

GetLevel - returns current log level

func (*LoggerConfig) Level

func (b *LoggerConfig) Level(level string) *LoggerConfig

Level - sets the logger level

func (*LoggerConfig) MaxAge

func (b *LoggerConfig) MaxAge(maxAge int) *LoggerConfig

MaxAge -

func (*LoggerConfig) MaxBackups

func (b *LoggerConfig) MaxBackups(maxBackups int) *LoggerConfig

MaxBackups -

func (*LoggerConfig) MaxMetricAge added in v1.1.80

func (b *LoggerConfig) MaxMetricAge(maxAge int) *LoggerConfig

MaxAge -

func (*LoggerConfig) MaxMetricBackups added in v1.1.80

func (b *LoggerConfig) MaxMetricBackups(maxBackups int) *LoggerConfig

MaxMetricBackups -

func (*LoggerConfig) MaxMetricSize added in v1.1.80

func (b *LoggerConfig) MaxMetricSize(maxSize int) *LoggerConfig

MaxMetricSize -

func (*LoggerConfig) MaxSize

func (b *LoggerConfig) MaxSize(maxSize int) *LoggerConfig

MaxSize -

func (*LoggerConfig) MaxUsageAge added in v1.1.83

func (b *LoggerConfig) MaxUsageAge(maxAge int) *LoggerConfig

func (*LoggerConfig) MaxUsageBackups added in v1.1.83

func (b *LoggerConfig) MaxUsageBackups(maxBackups int) *LoggerConfig

func (*LoggerConfig) MaxUsageSize added in v1.1.83

func (b *LoggerConfig) MaxUsageSize(maxSize int) *LoggerConfig

func (*LoggerConfig) MetricFilename added in v1.1.80

func (b *LoggerConfig) MetricFilename(filename string) *LoggerConfig

Filename -

func (*LoggerConfig) Metrics added in v1.1.80

func (b *LoggerConfig) Metrics(enabled bool) *LoggerConfig

func (*LoggerConfig) Output

func (b *LoggerConfig) Output(output string) *LoggerConfig

Output - sets how the logs will be tracked

func (*LoggerConfig) Path

func (b *LoggerConfig) Path(path string) *LoggerConfig

Path -

func (*LoggerConfig) Usage added in v1.1.83

func (b *LoggerConfig) Usage(enabled bool) *LoggerConfig

func (*LoggerConfig) UsageFilename added in v1.1.83

func (b *LoggerConfig) UsageFilename(filename string) *LoggerConfig

type LoggingFormat

type LoggingFormat int

LoggingFormat - Defines the format of the logging output

const (
	// Line - logs individual lines, preceded by the timestamp and level
	Line LoggingFormat = iota + 1
	// JSON - logs in JSON format with the timestamp, level, and message all being separate fields
	JSON
)

type LoggingOutput

type LoggingOutput int

LoggingOutput - Defines how the logger will log its output

const (
	// STDOUT - logs to the standard output of the agent process
	STDOUT LoggingOutput = iota
	// File - logs to a file, configure file settings for more options
	File
	// Both - logs to stdout and file, see the file confugration settings
	Both
)

type Redactor

type Redactor interface {
	DebugRedacted(fields []string, args ...interface{})
	ErrorRedacted(fields []string, args ...interface{})
	InfoRedacted(fields []string, args ...interface{})
	TraceRedacted(fields []string, args ...interface{})
}

Redactor interface for redacting log messages

type StdLogger

type StdLogger interface {
	Redactor
	logrus.StdLogger

	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Debugln(args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Errorln(args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Infoln(args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Warnln(args ...interface{})

	Trace(args ...interface{})
	Tracef(format string, args ...interface{})
	Traceln(args ...interface{})
}

StdLogger interface for logging methods found in the go standard library logger, and logrus methods.

Jump to

Keyboard shortcuts

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