Documentation ¶
Overview ¶
Package log provides a logging package.
Index ¶
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func NewDefaultWriter() io.WriteCloser
- func NewFileWriter(filename string, maxSize int64) (io.WriteCloser, error)
- func NewNilWriter() io.WriteCloser
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func SetFormatter(formatter Formatter)
- func SetLevel(lvl Level)
- func SetWriter(writer io.WriteCloser)
- func Setup(cfg Config) error
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Config
- type Entry
- type Formatter
- type Level
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultWriter ¶
func NewDefaultWriter() io.WriteCloser
NewDefaultWriter will return a writer that writes to Stdout
func NewFileWriter ¶
func NewFileWriter(filename string, maxSize int64) (io.WriteCloser, error)
NewFileWriter will return a writer that writes to the given file up to the maxSize after which it will it will rotate the file. If maxSize is set to 0, then it will not rotate the file.
func NewNilWriter ¶
func NewNilWriter() io.WriteCloser
NewNilWriter will return a writer that does nothing
func SetFormatter ¶
func SetFormatter(formatter Formatter)
func SetWriter ¶
func SetWriter(writer io.WriteCloser)
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry represents a user log entry with additional metadata
type Formatter ¶
Formatter is responsible to generate a byte array representing a log event in a specific format (json/txt/xml/etc)
func NewJSONFormatter ¶
NewJSONFormatter will encode the entry along with the default provided keys as a JSON string
func NewNilFormatter ¶
func NewNilFormatter() Formatter
NewNilFormatter will return a Formatter that does nothing and returns an empty byte slice every time
func NewTextFormatter ¶
NewTextFormatter will return encode the Entry along with the default provided keys as key=value pairs
type Level ¶
type Level byte
Level of severity for a log entry
const ( // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel Level = iota + 1 // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ErrorLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel )