Documentation ¶
Index ¶
- Constants
- Variables
- func AddHook(hook Hook)
- func FromStackContext(ctx context.Context) error
- func FromTagContext(ctx context.Context) string
- func FromTraceIDContext(ctx context.Context) string
- func FromUserIDContext(ctx context.Context) string
- func InitLogger(config Config) (func(), error)
- func NewStackContext(ctx context.Context, stack error) context.Context
- func NewTagContext(ctx context.Context, tag string) context.Context
- func NewTraceIDContext(ctx context.Context, traceID string) context.Context
- func NewUserIDContext(ctx context.Context, userID types.ID) context.Context
- func SetFormatter(format string)
- func SetLevel(level int)
- func SetOutput(out io.Writer)
- type Config
- type Entry
- type Fields
- type Hook
- type Logger
Constants ¶
View Source
const ( TraceIDKey = "traceID" UserIDKey = "userID" TagKey = "tag" StackKey = "stack" )
Define key
Variables ¶
View Source
var ( Tracef = logrus.Tracef Debugf = logrus.Debugf Debug = logrus.Debug Info = logrus.Info Infof = logrus.Infof Warnf = logrus.Warnf Warn = logrus.Warn Errorf = logrus.Errorf Error = logrus.Error Fatalf = logrus.Fatalf Fatal = logrus.Fatal Panicf = logrus.Panicf Panic = logrus.Panic Printf = logrus.Printf Print = logrus.Print )
Define logrus alias
Functions ¶
func FromStackContext ¶
FromStackContext 从上下文中获取Stack
func FromTraceIDContext ¶
FromTraceIDContext 从上下文中获取跟踪ID
func FromUserIDContext ¶
FromUserIDContext 从上下文中获取用户ID
func NewStackContext ¶
NewStackContext 创建Stack上下文
func NewTagContext ¶
NewTagContext 创建Tag上下文
func NewTraceIDContext ¶
NewTraceIDContext 创建跟踪ID上下文
func NewUserIDContext ¶
NewUserIDContext 创建用户ID上下文
Types ¶
type Config ¶
type Config struct { Level int `yaml:"level"` Format string `yaml:"format"` Output string `yaml:"output"` OutputFileDir string `yaml:"outputFileDir"` LogSoftLink string `yaml:"logSoftLink"` }
Config log 配置
Click to show internal directories.
Click to hide internal directories.