log

package
v0.0.0-...-85aee89 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

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 AddHook

func AddHook(hook Hook)

AddHook 增加日志钩子

func FromStackContext

func FromStackContext(ctx context.Context) error

FromStackContext 从上下文中获取Stack

func FromTagContext

func FromTagContext(ctx context.Context) string

FromTagContext 从上下文中获取Tag

func FromTraceIDContext

func FromTraceIDContext(ctx context.Context) string

FromTraceIDContext 从上下文中获取跟踪ID

func FromUserIDContext

func FromUserIDContext(ctx context.Context) string

FromUserIDContext 从上下文中获取用户ID

func InitLogger

func InitLogger(config Config) (func(), error)

InitLogger 初始化日志

func NewStackContext

func NewStackContext(ctx context.Context, stack error) context.Context

NewStackContext 创建Stack上下文

func NewTagContext

func NewTagContext(ctx context.Context, tag string) context.Context

NewTagContext 创建Tag上下文

func NewTraceIDContext

func NewTraceIDContext(ctx context.Context, traceID string) context.Context

NewTraceIDContext 创建跟踪ID上下文

func NewUserIDContext

func NewUserIDContext(ctx context.Context, userID types.ID) context.Context

NewUserIDContext 创建用户ID上下文

func SetFormatter

func SetFormatter(format string)

SetFormatter 设定日志输出格式

func SetLevel

func SetLevel(level int)

SetLevel 设定日志级别

func SetOutput

func SetOutput(out io.Writer)

SetOutput 设定日志输出

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 配置

type Entry

type Entry = logrus.Entry

Entry Logrus entry

func WithContext

func WithContext(ctx context.Context) *Entry

WithContext 使用上下文创建Entry

func WithField

func WithField(key string, value interface{}) *Entry

WithField 设置字段

func WithFields

func WithFields(fields Fields) *Entry

WithFields 设置字段

type Fields

type Fields = logrus.Fields

Fields Logrus

type Hook

type Hook = logrus.Hook

Hook 定义日志钩子别名

type Logger

type Logger = logrus.Logger

Logger Logrus

Jump to

Keyboard shortcuts

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