Documentation ¶
Index ¶
- Constants
- Variables
- func CanLogAt(logger *logrus.Logger, level logrus.Level) bool
- func GetLevel(logger *logrus.Logger) logrus.Level
- func InitializeDefaultLogger() *logrus.Logger
- func MultiLine(logFn func(args ...interface{}), output string)
- func SetLogLevel(level logrus.Level)
- func SetupLogging(loggers []string, logOpts map[string]string, tag string, debug bool) error
- func ToggleDebugLogs(debug bool)
Constants ¶
const ( SLevel = "syslog.level" Syslog = "syslog" )
Variables ¶
var ( // DefaultLogger is the base logrus logger. It is different from the logrus // default to avoid external dependencies from writing out unexpectedly DefaultLogger = InitializeDefaultLogger() // DefaultLogLevel is the alternative we provide to Debug DefaultLogLevel = logrus.InfoLevel // DefaultLogLevelStr is the string representation of DefaultLogLevel. It // is used to allow for injection of the logging level via go's ldflags in // unit tests, as only injection with strings via ldflags is allowed. DefaultLogLevelStr = "info" // LevelStringToLogrusLevel maps string representations of logrus.Level into // their corresponding logrus.Level. LevelStringToLogrusLevel = map[string]logrus.Level{ "panic": logrus.PanicLevel, "error": logrus.ErrorLevel, "warning": logrus.WarnLevel, "info": logrus.InfoLevel, "debug": logrus.DebugLevel, } )
Functions ¶
func CanLogAt ¶
CanLogAt returns whether a log message at the given level would be logged by the given logger.
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 SetLogLevel ¶
SetLogLevel sets the log level on DefaultLogger. This logger is, by convention, the base logger for package specific ones thus setting the level here impacts the default logging behaviour. This function is thread-safe when logging, reading DefaultLogger.Level is not protected this way, however.
func SetupLogging ¶
SetupLogging sets up each logging service provided in loggers and configures each logger with the provided logOpts.
func ToggleDebugLogs ¶
func ToggleDebugLogs(debug bool)
ToggleDebugLogs switches on or off debugging logs. It will select DefaultLogLevel when turning debug off. It is thread-safe.
Types ¶
This section is empty.