logging

package
v0.0.0-...-db02da0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Syslog    = "syslog"
	LevelOpt  = "level"
	FormatOpt = "format"

	LogFormatText          LogFormat = "text"
	LogFormatJSON          LogFormat = "json"
	LogFormatJSONTimestamp LogFormat = "json-ts"

	// DefaultLogFormat is the string representation of the default logrus.Formatter
	// we want to use (possible values: text or json)
	DefaultLogFormat LogFormat = LogFormatText

	// DefaultLogLevel is the default log level we want to use for our logrus.Formatter
	DefaultLogLevel logrus.Level = logrus.InfoLevel
)
View Source
const (
	SLevel    = "syslog.level"
	SNetwork  = "syslog.network"
	SAddress  = "syslog.address"
	SSeverity = "syslog.severity"
	SFacility = "syslog.facility"
	STag      = "syslog.tag"
)

Variables

View Source
var DefaultLogger = InitializeDefaultLogger()

DefaultLogger is the base logrus logger. It is different from the logrus default to avoid external dependencies from writing out unexpectedly

Functions

func AddHooks

func AddHooks(hooks ...logrus.Hook)

AddHooks adds additional logrus hook to default logger

func CanLogAt

func CanLogAt(logger *logrus.Logger, level logrus.Level) bool

CanLogAt returns whether a log message at the given level would be logged by the given logger.

func GetFormatter

func GetFormatter(format LogFormat) logrus.Formatter

GetFormatter returns a configured logrus.Formatter with some specific values we want to have

func GetLevel

func GetLevel(logger *logrus.Logger) logrus.Level

GetLevel returns the log level of the given logger.

func InitializeDefaultLogger

func InitializeDefaultLogger() (logger *logrus.Logger)

InitializeDefaultLogger returns a logrus Logger with a custom text formatter.

func MultiLine

func MultiLine(logFn func(args ...interface{}), output string)

MultiLine breaks a multi line text into individual log entries and calls the logging function to log each entry

func SetDefaultLogFormat

func SetDefaultLogFormat()

SetDefaultLogFormat updates the DefaultLogger with the DefaultLogFormat

func SetDefaultLogLevel

func SetDefaultLogLevel()

SetDefaultLogLevel updates the DefaultLogger with the DefaultLogLevel

func SetLogFormat

func SetLogFormat(logFormat LogFormat)

SetLogFormat updates the DefaultLogger with a new LogFormat

func SetLogLevel

func SetLogLevel(logLevel logrus.Level)

SetLogLevel updates the DefaultLogger with a new logrus.Level

func SetLogLevelToDebug

func SetLogLevelToDebug()

SetLogLevelToDebug updates the DefaultLogger with the logrus.DebugLevel

func SetupLogging

func SetupLogging(loggers []string, logOpts LogOptions, tag string, debug bool) error

SetupLogging sets up each logging service provided in loggers and configures each logger with the provided logOpts.

Types

type LogFormat

type LogFormat string

type LogOptions

type LogOptions map[string]string

LogOptions maps configuration key-value pairs related to logging.

func (LogOptions) GetLogFormat

func (o LogOptions) GetLogFormat() LogFormat

GetLogFormat returns the log format specified in the provided LogOptions. If it is not set in the options or is invalid, it will return the default format.

func (LogOptions) GetLogLevel

func (o LogOptions) GetLogLevel() (level logrus.Level)

GetLogLevel returns the log level specified in the provided LogOptions. If it is not set in the options, it will return the default level.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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