Documentation
¶
Index ¶
- func Close() (err error)
- func Error(format string, args ...interface{})
- func Errorv(ctx context.Context, args ...D)
- func Info(format string, args ...interface{})
- func Infov(ctx context.Context, args ...D)
- func Init(conf *Config)
- func Warn(format string, args ...interface{})
- func Warnv(ctx context.Context, args ...D)
- type AgentConfig
- type Config
- type D
- type FileHandler
- type Handler
- type Handlers
- type Level
- type Render
- type StdoutHandler
- type Verbose
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(format string, args ...interface{})
Error logs a message at the error log level.
func Info ¶
func Info(format string, args ...interface{})
Info logs a message at the info log level.
Types ¶
type AgentConfig ¶
type Config ¶
type Config struct { Family string Host string // stdout Stdout bool // file Dir string // buffer size FileBufferSize int64 // MaxLogFile MaxLogFile int // RotateSize RotateSize int64 // V Enable V-leveled logging at the specified level. V int32 // Module="" // The syntax of the argument is a map of pattern=N, // where pattern is a literal file name (minus the ".go" suffix) or // "glob" pattern and N is a V level. For instance: // [module] // "service" = 1 // "dao*" = 2 // sets the V level to 2 in all Go files whose names begin "dao". Module map[string]int32 // Filter tell log handler which field are sensitive message, use * instead. Filter []string }
Config log config.
type D ¶
type D struct { Key string Value interface{} }
D 表示用于结构化日志记录的入门级数据的映射。 type D map[string]interface{}
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
FileHandler .
func NewFile ¶
func NewFile(dir string, bufferSize, rotateSize int64, maxLogFile int) *FileHandler
NewFile crete a file logger.
func (*FileHandler) Log ¶
func (h *FileHandler) Log(ctx context.Context, lv Level, args ...D)
Log loggint to file .
func (*FileHandler) SetFormat ¶
func (h *FileHandler) SetFormat(format string)
SetFormat set log format
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers a bundle for hander with filter function.
type Render ¶
type Render interface { Render(io.Writer, map[string]interface{}) error RenderString(map[string]interface{}) string }
Render render log output
type StdoutHandler ¶
type StdoutHandler struct {
// contains filtered or unexported fields
}
StdoutHandler stdout log handler
func (*StdoutHandler) Log ¶
func (h *StdoutHandler) Log(ctx context.Context, lv Level, args ...D)
Log stdout loging, only for developing env.
func (*StdoutHandler) SetFormat ¶
func (h *StdoutHandler) SetFormat(format string)
SetFormat set stdout log output format %T time format at "15:04:05.999" %t time format at "15:04:05" %D data format at "2006/01/02" %d data format at "01/02" %L log level e.g. INFO WARN ERROR %f function name and line number e.g. model.Get:121 %i instance id %e deploy env e.g. dev uat fat prod %z zone %S full file name and line number: /a/b/c/d.go:23 %s final file name element and line number: d.go:23 %M log message and additional fields: key=value this is log message