logging

package
v0.16.11 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RFC3339Milli = "2006-01-02T15:04:05.000Z07:00"
)

Variables

View Source
var NullLogger = &Logger{
	underlying: zerolog.Nop(),
}

NullLogger is Logger that discards all log lines

View Source
var (
	StdSkipFrames = 4
)

Functions

func ConfigureApplicationLogging added in v0.16.5

func ConfigureApplicationLogging() error

ConfigureApplicationLogging sets up logging suitable for an application. Logging configuration is loaded from a filepath given by the ARMADA_LOG_CONFIG environmental variable or from config/logging.yaml if this var is unset.

func ConfigureCliLogging added in v0.16.5

func ConfigureCliLogging()

func Debug added in v0.16.2

func Debug(args ...any)

Debug logs a message at level Debug on the default logger.

func Debugf added in v0.16.2

func Debugf(format string, args ...any)

Debugf logs a message at level Debug on the default logger.

func Error added in v0.16.2

func Error(args ...any)

Error logs a message at level Error on the default logger.

func Errorf added in v0.16.2

func Errorf(format string, args ...any)

Errorf logs a message at level Error on the default logger.

func Fatal added in v0.16.2

func Fatal(args ...any)

Fatal logs a message at level Fatal on the default logger then the process will exit with status set to 1.

func Fatalf added in v0.16.2

func Fatalf(format string, args ...any)

Fatalf logs a message at level Fatal on the default logger then the process will exit with status set to 1.

func Info added in v0.16.2

func Info(args ...any)

Info logs a message at level Info on the default logger.

func Infof added in v0.16.2

func Infof(format string, args ...any)

Infof logs a message at level Info on the default logger.

func MustConfigureApplicationLogging added in v0.16.5

func MustConfigureApplicationLogging()

MustConfigureApplicationLogging sets up logging suitable for an application. Logging configuration is loaded from a filepath given by the ARMADA_LOG_CONFIG environmental variable or from config/logging.yaml if this var is unset. Note that this function will immediately shut down the application if it fails.

func NewPulsarLogger added in v0.16.2

func NewPulsarLogger() pulsarlog.Logger

NewPulsarLogger returns a Logger that can be used by the pulsar client

func Panic added in v0.16.2

func Panic(args ...any)

Panic logs a message at level Panic on the default logger.

func ReplaceStdLogger added in v0.16.2

func ReplaceStdLogger(l *Logger)

ReplaceStdLogger Replaces the global logger. This should be called once at app startup!

func Warn added in v0.16.2

func Warn(args ...any)

Warn logs a message at level Warn on the default logger.

func Warnf added in v0.16.2

func Warnf(format string, args ...any)

Warnf logs a message at level Warn on the default logger.

Types

type Config added in v0.16.5

type Config struct {
	// Defines configuration for console logging on stdout
	Console struct {
		// Log level, e.g. INFO, ERROR etc
		Level string `yaml:"level"`
		// Logging format, either text, json or colourful
		Format LogFormat `yaml:"format"`
	} `yaml:"console"`
	// Defines configuration for file logging
	File struct {
		// Whether file logging is enabled.
		Enabled bool `yaml:"enabled"`
		// Log level, e.g. INFO, ERROR etc
		Level string `yaml:"level"`
		// Logging format, either text, json or or colourful
		Format LogFormat `yaml:"format"`
		// The Location of the logfile on disk
		LogFile string `yaml:"logfile"`
		// Log Rotation Options
		Rotation struct {
			// Whether Log Rotation is enabled
			Enabled bool `yaml:"enabled"`
			// Maximum size in megabytes of the log file before it gets rotated
			MaxSizeMb int `yaml:"maxSizeMb"`
			// Maximum number of old log files to retain
			MaxBackups int `yaml:"maxBackups"`
			// Maximum number of days to retain old log files
			MaxAgeDays int `yaml:"maxAgeDays"`
			// Whether to compress rotated log files
			Compress bool `yaml:"compress"`
		} `yaml:"rotation"`
	} `yaml:"file"`
}

Config defines Armada logging configuration.

type FilteredLevelWriter added in v0.16.2

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

func (*FilteredLevelWriter) Write added in v0.16.2

func (w *FilteredLevelWriter) Write(p []byte) (int, error)

Write writes to the underlying Writer.

func (*FilteredLevelWriter) WriteLevel added in v0.16.2

func (w *FilteredLevelWriter) WriteLevel(level zerolog.Level, p []byte) (int, error)

WriteLevel calls WriteLevel of the underlying Writer only if the level is equal or above the Level.

type LogFormat added in v0.16.5

type LogFormat string
const (
	FormatText      LogFormat = "text"
	FormatJSON      LogFormat = "json"
	FormatColourful LogFormat = "colourful"
)

Allowed values for LogFormat.

func (*LogFormat) UnmarshalYAML added in v0.16.5

func (lf *LogFormat) UnmarshalYAML(value *yaml.Node) error

type Logger added in v0.16.2

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

Logger wraps a zerolog.Logger so that the rest of the code doesn't depend directly on zerolog

func FromZerolog added in v0.16.2

func FromZerolog(l zerolog.Logger) *Logger

FromZerolog returns a new Logger backed by the supplied zerolog.Logger

func StdLogger added in v0.16.2

func StdLogger() *Logger

StdLogger Returns the default logger

func WithError added in v0.16.2

func WithError(err error) *Logger

WithError returns a new Logger with the error added as a field

func WithField added in v0.16.2

func WithField(key string, value any) *Logger

WithField returns a new Logger with the key-value pair added as a new field

func WithFields added in v0.16.2

func WithFields(args map[string]any) *Logger

WithFields returns a new Logger with all key-value pairs in the map added as new fields

func WithStacktrace

func WithStacktrace(err error) *Logger

WithStacktrace returns a new Logger with the error and (if available) the stacktrace added as fields

func (*Logger) Debug added in v0.16.2

func (l *Logger) Debug(args ...any)

Debug logs a message at level Debug

func (*Logger) Debugf added in v0.16.2

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

Debugf logs a formatted message at level Debug

func (*Logger) Error added in v0.16.2

func (l *Logger) Error(args ...any)

Error logs a message at level Error

func (*Logger) Errorf added in v0.16.2

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

Errorf logs a formatted message at level Error

func (*Logger) Fatal added in v0.16.2

func (l *Logger) Fatal(args ...any)

Fatal logs a message at level Fatal and exits the application

func (*Logger) Fatalf added in v0.16.2

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf logs a formatted message at level Fatal and exits the application

func (*Logger) Info added in v0.16.2

func (l *Logger) Info(args ...any)

Info logs a message at level Info

func (*Logger) Infof added in v0.16.2

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

Infof logs a formatted message at level Info

func (*Logger) Panic added in v0.16.2

func (l *Logger) Panic(args ...any)

Panic logs a message at level Panic and panics

func (*Logger) Warn added in v0.16.2

func (l *Logger) Warn(args ...any)

Warn logs a message at level Warn

func (*Logger) Warnf added in v0.16.2

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

Warnf logs a formatted message at level Warn

func (*Logger) WithCallerSkip added in v0.16.2

func (l *Logger) WithCallerSkip(skip int) *Logger

WithCallerSkip returns a new Logger with the number of callers skipped increased by the skip amount. This is needed when building wrappers around the Logger so as to prevent us from always reporting the wrapper code as the caller.

func (*Logger) WithError added in v0.16.2

func (l *Logger) WithError(err error) *Logger

WithError returns a new Logger with the error added as a field

func (*Logger) WithField added in v0.16.2

func (l *Logger) WithField(key string, value any) *Logger

WithField returns a new Logger with the key-value pair added as a new field

func (*Logger) WithFields added in v0.16.2

func (l *Logger) WithFields(args map[string]any) *Logger

WithFields returns a new Logger with all key-value pairs in the map added as new fields

func (*Logger) WithStacktrace added in v0.16.2

func (l *Logger) WithStacktrace(err error) *Logger

WithStacktrace returns a new Logger with the error and (if available) the stacktrace added as fields

type PrometheusHook added in v0.16.2

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

PrometheusHook implements zerolog.Hook

func NewPrometheusHook added in v0.16.2

func NewPrometheusHook() *PrometheusHook

NewPrometheusHook creates and registers Prometheus counters for each log level.

func (*PrometheusHook) Run added in v0.16.2

func (h *PrometheusHook) Run(_ *zerolog.Event, level zerolog.Level, _ string)

Jump to

Keyboard shortcuts

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