Documentation ¶
Overview ¶
@Time : 2018/8/16 12:46 @Author : kenny zhu @File : interface.go @Software: GoLand @Others: Default operations.
Package log is an interface for structured logging.
Index ¶
- Constants
- 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 GetFunctionName(i interface{}, seps ...rune) string
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func InitLogger(opts ...Option)
- func NewContext(ctx context.Context, c Log) context.Context
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Event
- type Fields
- type Level
- type Log
- type Logger
- type Option
- type Options
- type Output
- type OutputOption
- type OutputOptions
Constants ¶
Variables ¶
View Source
var ( DefaultLevel Level = InfoLevel DefaultOutputName = "server.log" // file sequences. FileSize int64 = DefaultFileSize Levels = map[Level]string{ DebugLevel: "debug", InfoLevel: "info", WarnLevel: "warn", ErrorLevel: "error", FatalLevel: "fatal", } )
Functions ¶
func GetFunctionName ¶
用 seps 进行分割, 根据协议栈信息查找...
func InitLogger ¶
func InitLogger(opts ...Option)
Types ¶
type Event ¶
type Event struct { Timestamp string `json:"timestamp"` Level Level `json:"level"` Fields Fields `json:"fields"` 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{}) Warn(args ...interface{}) // sjlin 新增漏掉接口 Error(args ...interface{}) Fatal(args ...interface{}) // Formatted logger Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) // sjlin 新增漏掉接口 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 // 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 OutputDir ¶
func OutputDir(dir string) OutputOption
type OutputOptions ¶
Click to show internal directories.
Click to hide internal directories.