Documentation ¶
Overview ¶
@Time : 2018/8/16 12:46 @Author : kenny zhu @File : interface.go @Software: GoLand @Others:
Package log is an interface for structured logging.
Index ¶
- Variables
- 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 InitLogger(opts ...Option)
- func NewContext(ctx context.Context, c Log) context.Context
- type Event
- type Fields
- type Level
- type Log
- type Logger
- type Option
- type Options
- type Output
- type OutputOption
- type OutputOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultLevel Level = InfoLevel DefaultOutputName = "log.json" Levels = map[Level]string{ DebugLevel: "debug", InfoLevel: "info", WarnLevel: "warn", ErrorLevel: "error", FatalLevel: "fatal", } )
Functions ¶
func InitLogger ¶
func InitLogger(opts ...Option)
Types ¶
type Event ¶
type Event struct { Level Level `json:"level"` Fields Fields `json:"fields"` Timestamp int64 `json:"timestamp"` Message string `json:"message"` }
Event represents a single log event
func (*Event) MarshalJSON ¶
type Logger ¶
type Logger interface { // Logger interface Debug(args ...interface{}) Info(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) // Formatted logger Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) // Specify your own levels Log(l Level, args ...interface{}) Logf(l Level, format string, args ...interface{}) // Returns with extra fields WithFields(f Fields) Logger }
type Output ¶
type Output interface { // Send an event Send(*Event) error // Flush any buffered events Flush() error // Discard the output Close() error // Name of output String() string }
An output represents a file, indexer, syslog, etc
func NewOutput ¶
func NewOutput(opts ...OutputOption) Output
type OutputOption ¶
type OutputOption func(o *OutputOptions)
func OutputName ¶
func OutputName(name string) OutputOption
type OutputOptions ¶
type OutputOptions struct { // filepath, url, etc Name string }
Click to show internal directories.
Click to hide internal directories.