mirror of https://github.com/sirupsen/logrus.git
88 lines
2.0 KiB
Go
88 lines
2.0 KiB
Go
package logrus
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
var (
|
|
// std is the name of the standard logger in stdlib `log`
|
|
std = New()
|
|
)
|
|
|
|
// SetOutput sets the standard logger output.
|
|
func SetOutput(out io.Writer) {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
std.Out = out
|
|
}
|
|
|
|
// SetFormatter sets the standard logger formatter.
|
|
func SetFormatter(formatter Formatter) {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
std.Formatter = formatter
|
|
}
|
|
|
|
// SetLevel sets the standard logger level.
|
|
func SetLevel(level Level) {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
std.Level = level
|
|
}
|
|
|
|
// AddHook adds a hook to the standard logger hooks.
|
|
func AddHook(hook Hook) {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
std.Hooks.Add(hook)
|
|
}
|
|
|
|
// WithField creates an entry from the standard 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 WithField(key string, value interface{}) *Entry {
|
|
return std.WithField(key, value)
|
|
}
|
|
|
|
// WithFields creates an entry from the standard 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.
|
|
func WithFields(fields Fields) *Entry {
|
|
return std.WithFields(fields)
|
|
}
|
|
|
|
// Debug logs a message at level Debug on the standard logger.
|
|
func Debug(args ...interface{}) {
|
|
std.Debug(args...)
|
|
}
|
|
|
|
// Info logs a message at level Info on the standard logger.
|
|
func Info(args ...interface{}) {
|
|
std.Info(args...)
|
|
}
|
|
|
|
// Warn logs a message at level Warn on the standard logger.
|
|
func Warn(args ...interface{}) {
|
|
std.Warn(args...)
|
|
}
|
|
|
|
// Error logs a message at level Error on the standard logger.
|
|
func Error(args ...interface{}) {
|
|
std.Error(args...)
|
|
}
|
|
|
|
// Panic logs a message at level Panic on the standard logger.
|
|
func Panic(args ...interface{}) {
|
|
std.Panic(args...)
|
|
}
|
|
|
|
// Fatal logs a message at level Fatal on the standard logger.
|
|
func Fatal(args ...interface{}) {
|
|
std.Fatal(args...)
|
|
}
|