Documentation ¶
Index ¶
- Constants
- Variables
- func AddHook(hook logrus.Hook)
- func ApplyConfig(config LogriConfig) error
- func ApplyConfigFromFile(file string) error
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func GetOutputWriter(outtype OutputType, options map[string]string) (io.Writer, error)
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Panicln(args ...interface{})
- func Print(args ...interface{})
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func SetLevel(level logrus.Level)
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warning(args ...interface{})
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- func Warnln(args ...interface{})
- func WatchConfigFile(file string) error
- func WithError(err error) *logrus.Entry
- func WithField(key string, value interface{}) *logrus.Entry
- func WithFields(fields logrus.Fields) *logrus.Entry
- type Logger
- func (l *Logger) AddHook(hook logrus.Hook)
- func (l *Logger) ApplyConfig(config LogriConfig) error
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Debugln(args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Errorln(args ...interface{})
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Fatalln(args ...interface{})
- func (l *Logger) GetChild(name string) *Logger
- func (l *Logger) GetEffectiveLevel() logrus.Level
- func (l *Logger) GetRoot() *Logger
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Infoln(args ...interface{})
- func (l *Logger) Panic(args ...interface{})
- func (l *Logger) Panicf(format string, args ...interface{})
- func (l *Logger) Panicln(args ...interface{})
- func (l *Logger) Print(args ...interface{})
- func (l *Logger) Printf(format string, args ...interface{})
- func (l *Logger) Println(args ...interface{})
- func (l *Logger) SetLevel(level logrus.Level, inherit bool) error
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) SetOutputs(writers ...io.Writer)
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) Warning(args ...interface{})
- func (l *Logger) Warningf(format string, args ...interface{})
- func (l *Logger) Warningln(args ...interface{})
- func (l *Logger) Warnln(args ...interface{})
- func (l *Logger) WithError(err error) *logrus.Entry
- func (l *Logger) WithField(key string, value interface{}) *logrus.Entry
- func (l *Logger) WithFields(fields logrus.Fields) *logrus.Entry
- type LoggerConfig
- type LoggerHook
- type LogriConfig
- type OutConfig
- type OutputType
Constants ¶
const ( FileOutput OutputType = "file" StdoutOutput = "stdout" StderrOutput = "stderr" TestOutput = "test" // Used for tests only )
Variables ¶
var (
ConfigurationError = errors.New("Unable to parse configuration")
)
var (
ErrInvalidOutputOptions = errors.New("Insufficient or invalid options were given for an output")
)
var ( // ErrInvalidRootLevel is returned when a nil level is set on the root logger ErrInvalidRootLevel = errors.New("The root logger must have a level") )
var ( // RootLogger is the default logger tree. RootLogger = NewLoggerFromLogrus(logrus.New()) )
Functions ¶
func ApplyConfig ¶
func ApplyConfig(config LogriConfig) error
ApplyConfig applies configuration to the default tree.
func ApplyConfigFromFile ¶
ApplyConfigFromFile reads logging configuration from a file and applies it to the default tree.
func Debug ¶
func Debug(args ...interface{})
Debug logs a message at level Debug on the standard logger.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a message at level Debug on the standard logger.
func Debugln ¶
func Debugln(args ...interface{})
Debugln logs a message at level Debug on the standard logger.
func Error ¶
func Error(args ...interface{})
Error logs a message at level Error on the standard logger.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a message at level Error on the standard logger.
func Errorln ¶
func Errorln(args ...interface{})
Errorln logs a message at level Error on the standard logger.
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs a message at level Fatal on the standard logger.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs a message at level Fatal on the standard logger.
func Fatalln ¶
func Fatalln(args ...interface{})
Fatalln logs a message at level Fatal on the standard logger.
func GetOutputWriter ¶
func Info ¶
func Info(args ...interface{})
Info logs a message at level Info on the standard logger.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs a message at level Info on the standard logger.
func Infoln ¶
func Infoln(args ...interface{})
Infoln logs a message at level Info on the standard logger.
func Panic ¶
func Panic(args ...interface{})
Panic logs a message at level Panic on the standard logger.
func Panicf ¶
func Panicf(format string, args ...interface{})
Panicf logs a message at level Panic on the standard logger.
func Panicln ¶
func Panicln(args ...interface{})
Panicln logs a message at level Panic on the standard logger.
func Print ¶
func Print(args ...interface{})
Print logs a message at level Info on the standard logger.
func Printf ¶
func Printf(format string, args ...interface{})
Printf logs a message at level Info on the standard logger.
func Println ¶
func Println(args ...interface{})
Println logs a message at level Info on the standard logger.
func Warn ¶
func Warn(args ...interface{})
Warn logs a message at level Warn on the standard logger.
func Warnf ¶
func Warnf(format string, args ...interface{})
Warnf logs a message at level Warn on the standard logger.
func Warning ¶
func Warning(args ...interface{})
Warning logs a message at level Warn on the standard logger.
func Warningf ¶
func Warningf(format string, args ...interface{})
Warningf logs a message at level Warn on the standard logger.
func Warningln ¶
func Warningln(args ...interface{})
Warningln logs a message at level Warn on the standard logger.
func Warnln ¶
func Warnln(args ...interface{})
Warnln logs a message at level Warn on the standard logger.
func WatchConfigFile ¶
WatchConfigFile watches a given config file, applying the config on change
func WithError ¶
WithError creates an entry from the root logger and adds an error to it, using the value defined in ErrorKey as key.
func WithField ¶
WithField creates an entry from the root logger and adds a field to it. If you want multiple fields, use `WithFields`.
Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.
func WithFields ¶
WithFields creates an entry from the root logger and adds multiple fields to it. This is simply a helper for `WithField`, invoking it once for each field.
Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.
Types ¶
type Logger ¶
type Logger struct { Name string // contains filtered or unexported fields }
Logger is the wrapper of a Logrus logger. It holds references to its child loggers, and manages transactional application of new levels and output streams.
func NewLoggerFromLogrus ¶
NewLoggerFromLogrus creates a new Logri logger tree rooted at a given Logrus logger.
func (*Logger) ApplyConfig ¶
func (l *Logger) ApplyConfig(config LogriConfig) error
ApplyConfig applies a Logrus config to a logger tree. Regardless of the logger within the tree to which the config is applied, it is treated as the root of the tree for purposes of configuring loggers.
func (*Logger) GetChild ¶
GetChild returns a logger that is a child of this logger, creating intervening loggers if they do not exist. If the name given starts with the full name of the current logger (i.e., is "absolute"), then the logger returned will take that into account, rather than creating a duplicate tree below this one.
Example:
logger := logri.Logger("a.b.c") // logger.name == "a.b.c" l := logger.GetChild("a.b.c.d") // l.name == "a.b.c.d" l = logger.GetChild("d") // l.name == "a.b.c.d" l = logger.GetChild("b.c.d") // l.name == "a.b.c.b.c.d"
func (*Logger) GetEffectiveLevel ¶
GetEffectiveLevel returns the effective level of this logger. If this logger has no level set locally, it returns the level of its closest ancestor with an inheritable level.
func (*Logger) SetLevel ¶
SetLevel sets the logging level for this logger and children inheriting their level from this logger. If inherit is false, the level will be set locally only.
func (*Logger) SetOutputs ¶
SetOutputs combines several output writers into one and configures this logger to write to that.
type LoggerConfig ¶
LoggerConfig is the configuration for a single logger
type LoggerHook ¶
type LoggerHook struct {
// contains filtered or unexported fields
}
LoggerHook is a Logrus hook that adds the logger name as a field to the entry
func (LoggerHook) Fire ¶
func (hook LoggerHook) Fire(entry *logrus.Entry) error
Fire satisfies the logrus.Hook interface
func (LoggerHook) Levels ¶
func (hook LoggerHook) Levels() []logrus.Level
Levels satisfies the logrus.Hook interface
type LogriConfig ¶
type LogriConfig []LoggerConfig
LogriConfig is the configuration for a logri manager
func ConfigFromBytes ¶
func ConfigFromBytes(b []byte) (LogriConfig, error)
func ConfigFromYAML ¶
func ConfigFromYAML(r io.Reader) (LogriConfig, error)
func (LogriConfig) Len ¶
func (c LogriConfig) Len() int
func (LogriConfig) Less ¶
func (c LogriConfig) Less(i, j int) bool
Sort loggers by depth in the hierarchy
func (LogriConfig) Swap ¶
func (c LogriConfig) Swap(i, j int)
type OutputType ¶
type OutputType string