Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigureApplicationLogging() error
- func ConfigureCliLogging()
- func Debug(args ...any)
- func Debugf(format string, args ...any)
- func Error(args ...any)
- func Errorf(format string, args ...any)
- func Fatal(args ...any)
- func Fatalf(format string, args ...any)
- func Info(args ...any)
- func Infof(format string, args ...any)
- func MustConfigureApplicationLogging()
- func NewPulsarLogger() pulsarlog.Logger
- func Panic(args ...any)
- func ReplaceStdLogger(l *Logger)
- func Warn(args ...any)
- func Warnf(format string, args ...any)
- type Config
- type FilteredLevelWriter
- type LogFormat
- type Logger
- func (l *Logger) Debug(args ...any)
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(args ...any)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(args ...any)
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(args ...any)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Panic(args ...any)
- func (l *Logger) Warn(args ...any)
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) WithCallerSkip(skip int) *Logger
- func (l *Logger) WithError(err error) *Logger
- func (l *Logger) WithField(key string, value any) *Logger
- func (l *Logger) WithFields(args map[string]any) *Logger
- func (l *Logger) WithStacktrace(err error) *Logger
- type PrometheusHook
Constants ¶
const (
RFC3339Milli = "2006-01-02T15:04:05.000Z07:00"
)
Variables ¶
var NullLogger = &Logger{ underlying: zerolog.Nop(), }
NullLogger is Logger that discards all log lines
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 Error ¶ added in v0.16.2
func Error(args ...any)
Error 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
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 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
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!
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
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
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
FromZerolog returns a new Logger backed by the supplied zerolog.Logger
func WithField ¶ added in v0.16.2
WithField returns a new Logger with the key-value pair added as a new field
func WithFields ¶ added in v0.16.2
WithFields returns a new Logger with all key-value pairs in the map added as new fields
func WithStacktrace ¶
WithStacktrace returns a new Logger with the error and (if available) the stacktrace added as fields
func (*Logger) Fatal ¶ added in v0.16.2
Fatal logs a message at level Fatal and exits the application
func (*Logger) Fatalf ¶ added in v0.16.2
Fatalf logs a formatted message at level Fatal and exits the application
func (*Logger) WithCallerSkip ¶ added in v0.16.2
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
WithError returns a new Logger with the error added as a field
func (*Logger) WithField ¶ added in v0.16.2
WithField returns a new Logger with the key-value pair added as a new field
func (*Logger) WithFields ¶ added in v0.16.2
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
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.