Documentation ¶
Index ¶
- Constants
- Variables
- func AddHooks(hooks ...logrus.Hook)
- func CanLogAt(logger *logrus.Logger, level logrus.Level) bool
- func GetFormatter(format LogFormat) logrus.Formatter
- func GetLevel(logger *logrus.Logger) logrus.Level
- func InitializeDefaultLogger() (logger *logrus.Logger)
- func MultiLine(logFn func(args ...interface{}), output string)
- func SetDefaultLogFormat()
- func SetDefaultLogLevel()
- func SetLogFormat(logFormat LogFormat)
- func SetLogLevel(logLevel logrus.Level)
- func SetLogLevelToDebug()
- func SetupLogging(loggers []string, logOpts LogOptions, tag string, debug bool) error
- type Limiter
- type LogFormat
- type LogOptions
Constants ¶
const ( Syslog = "syslog" LevelOpt = "level" FormatOpt = "format" LogFormatText LogFormat = "text" LogFormatJSON LogFormat = "json" // 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 )
const ( SLevel = "syslog.level" SNetwork = "syslog.network" SAddress = "syslog.address" SSeverity = "syslog.severity" SFacility = "syslog.facility" STag = "syslog.tag" )
Variables ¶
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 CanLogAt ¶
CanLogAt returns whether a log message at the given level would be logged by the given logger.
func GetFormatter ¶ added in v1.14.0
GetFormatter returns a configured logrus.Formatter with some specific values we want to have
func InitializeDefaultLogger ¶
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 ¶ added in v1.14.0
func SetDefaultLogFormat()
SetDefaultLogFormat updates the DefaultLogger with the DefaultLogFormat
func SetDefaultLogLevel ¶ added in v1.14.0
func SetDefaultLogLevel()
SetDefaultLogLevel updates the DefaultLogger with the DefaultLogLevel
func SetLogFormat ¶ added in v1.14.0
func SetLogFormat(logFormat LogFormat)
SetLogFormat updates the DefaultLogger with a new LogFormat
func SetLogLevel ¶
SetLogLevel updates the DefaultLogger with a new logrus.Level
func SetLogLevelToDebug ¶ added in v1.14.0
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 Limiter ¶ added in v1.14.0
type Limiter struct {
// contains filtered or unexported fields
}
Limiter is a wrapper around rate.Limiter that does not panic when the limiter is uninitialized. The wrapping also allows more logging specific functionality to be added later without changing all the call sites.
func NewLimiter ¶ added in v1.14.0
NewLimiter returns a new Limiter allowing log messages to be emitted on average once every 'interval' and upto 'burst' messages during any 'interval'.
type LogOptions ¶ added in v1.14.0
LogOptions maps configuration key-value pairs related to logging.
func (LogOptions) GetLogFormat ¶ added in v1.14.0
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 ¶ added in v1.14.0
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.