logging

package
v1.15.0-pre.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 15 Imported by: 516

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