log

package
v1.1.25 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 10 Imported by: 3

README

log zap日志库

zap_test.go

TestZap

ctx := &gin.Context{}
ctx.Set(LOG_TRADE_ID, "aaabbbbbcccc")

Info(ctx, "我是日志2")
Error(ctx, "我是日志4: %v,%v", "管理员", "eee")
TestPanicLog

testPanicLog()

Info(context.Background(), "catch panic")
TestLevelChange

traceId := strings.Replace(uuid.New().String(), "-", "", -1)
ctx := context.WithValue(context.Background(), LOG_TRADE_ID, traceId)
Error(ctx, LogLess())
Error(ctx, LogLess())
Error(ctx, LogLess())
Error(ctx, LogLess())
Error(ctx, LogLess())
Error(ctx, LogLess())
Error(ctx, LogLess())
Error(ctx, LogLess())

fmt.Println(LogLess(), "============")

Info(ctx, LogMore())
Info(ctx, LogMore())
Info(ctx, LogMore())
Info(ctx, LogMore())
Info(ctx, LogMore())
Info(ctx, LogMore())
Info(ctx, LogMore())
Info(ctx, LogMore())

fmt.Println(LogMore(), "============")

Documentation

Index

Constants

View Source
const LOG_TRADE_ID = "__GTraceId__"

Variables

This section is empty.

Functions

func CnTimeEncoder

func CnTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

func Debug

func Debug(c context.Context, args ...interface{})

func Error

func Error(c context.Context, args ...interface{})

func ErrorStack added in v1.1.25

func ErrorStack(c context.Context, args ...interface{})

func Fatal

func Fatal(c context.Context, args ...interface{})

func Info

func Info(c context.Context, args ...interface{})

func Log

func Log(c context.Context, level zapcore.Level, args ...interface{})

func LogLess

func LogLess() zapcore.Level

func LogMore

func LogMore() zapcore.Level

func Panic

func Panic(c context.Context, args ...interface{})

func Recover

func Recover(c context.Context, errHandler func(interface{}) string)

func Warn

func Warn(c context.Context, args ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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