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 LogFormat
- type LogOptions
Constants ¶
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 )
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 ¶
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 ¶
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 ¶
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 LogOptions ¶
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.