logs

package
v0.0.0-...-56f3d1a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 50

Documentation

Index

Constants

View Source
const (
	CommFieldLogId  = "log_id"
	CommFieldSubMod = "s_mod"
	CommFieldPid    = "pid"
	CommFieldCall   = "call"
)

Reserve common key

View Source
const (
	DefaultCallDepth = 4
)

Variables

This section is empty.

Functions

func InitLog

func InitLog(cfgFile, logDir string)

基础初始化操作,出现错误会panic抛出异常

Types

type LogDriver

type LogDriver interface {
	Error(msg string, ctx ...interface{})
	Warn(msg string, ctx ...interface{})
	Info(msg string, ctx ...interface{})
	Trace(msg string, ctx ...interface{})
	Debug(msg string, ctx ...interface{})
}

底层日志库约束接口

func OpenLog

func OpenLog(lc *lconf.LogConf, logDir string) (LogDriver, error)

OpenLog create and open log stream using LogConfig

type LogFitter

type LogFitter struct {
	// contains filtered or unexported fields
}

Logger Fitter 方便系统对日志输出做自定义扩展

func NewLogger

func NewLogger(logId, subMod string) (*LogFitter, error)

需要先调用InitLog全局初始化

func (*LogFitter) Debug

func (t *LogFitter) Debug(msg string, ctx ...interface{})

func (*LogFitter) Error

func (t *LogFitter) Error(msg string, ctx ...interface{})

func (*LogFitter) GetLogId

func (t *LogFitter) GetLogId() string

func (*LogFitter) Info

func (t *LogFitter) Info(msg string, ctx ...interface{})

func (*LogFitter) SetCommField

func (t *LogFitter) SetCommField(key string, value interface{})

func (*LogFitter) SetInfoField

func (t *LogFitter) SetInfoField(key string, value interface{})

func (*LogFitter) Trace

func (t *LogFitter) Trace(msg string, ctx ...interface{})

func (*LogFitter) Warn

func (t *LogFitter) Warn(msg string, ctx ...interface{})

type Logger

type Logger interface {
	GetLogId() string
	SetCommField(key string, value interface{})
	SetInfoField(key string, value interface{})
	Error(msg string, ctx ...interface{})
	Warn(msg string, ctx ...interface{})
	Info(msg string, ctx ...interface{})
	Trace(msg string, ctx ...interface{})
	Debug(msg string, ctx ...interface{})
}

在日志库之上做一层轻量级封装,方便日志字段组装和日志库替换 对外提供功能接口

type Lvl

type Lvl int

Lvl is a type for predefined log levels.

const (
	LvlCrit Lvl = iota
	LvlError
	LvlWarn
	LvlInfo
	LvlTrace
	LvlDebug
)

List of predefined log Levels

func LvlFromString

func LvlFromString(lvlString string) Lvl

LvlFromString returns the appropriate Lvl from a string name. Useful for parsing command line args and configuration files.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL