Documentation
¶
Index ¶
- Constants
- Variables
- func DPanic(ctx context.Context, msg string, fields ...zap.Field)
- func Debug(ctx context.Context, msg string, fields ...zap.Field)
- func DebugKV(ctx context.Context, msg string, kvs ...any)
- func Debugf(ctx context.Context, format string, args ...any)
- func Error(ctx context.Context, msg string, fields ...zap.Field)
- func ErrorKV(ctx context.Context, msg string, kvs ...any)
- func Errorf(ctx context.Context, format string, args ...any)
- func Fatal(ctx context.Context, msg string, fields ...zap.Field)
- func GetLogger(key string) *zap.Logger
- func GetTraceID(ctx context.Context) string
- func Info(ctx context.Context, msg string, fields ...zap.Field)
- func InfoKV(ctx context.Context, msg string, kvs ...any)
- func Infof(ctx context.Context, format string, args ...any)
- func LevelOf(level Level) zapcore.Level
- func MaskEmail(email string) string
- func MaskPhone(phone string) string
- func MaskString(s string, prefixLen, suffixLen int) string
- func MaskToken(token string) string
- func NewCtx(traceIds ...string) context.Context
- func Panic(ctx context.Context, msg string, fields ...zap.Field)
- func Sugar(ctx context.Context) *zap.SugaredLogger
- func Warn(ctx context.Context, msg string, fields ...zap.Field)
- func WarnKV(ctx context.Context, msg string, kvs ...any)
- func Warnf(ctx context.Context, format string, args ...any)
- func With(fields ...zap.Field) *zap.Logger
- func WithContext(ctx context.Context) *zap.Logger
- type Level
Constants ¶
View Source
const ( DebugLevel = "debug" InfoLevel = "info" WarnLevel = "warn" ErrorLevel = "error" )
Variables ¶
View Source
var Console *zap.Logger
View Source
var Logger *zap.Logger
Functions ¶
func GetTraceID ¶
func MaskString ¶
MaskString masks middle characters of a string, keeping prefix and suffix characters.
func MaskToken ¶
MaskToken masks sensitive tokens (e.g., Bearer tokens, API keys, JWTs), keeping header and tail characters.
func Sugar ¶
func Sugar(ctx context.Context) *zap.SugaredLogger
Sugar returns a sugared logger with context fields attached.
Types ¶
Click to show internal directories.
Click to hide internal directories.