log

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Always

func Always(msg string, fields ...zap.Field)

Always logs a message at InfoLevel, ignoring the global log level

func C

func C(ctx context.Context) *zap.Logger

C returns a logger with context fields (trace_id, user_id, etc.)

func CDebug

func CDebug(ctx context.Context, msg string, fields ...zap.Field)

CDebug logs a message with context fields

func CError

func CError(ctx context.Context, msg string, fields ...zap.Field)

CError logs a message with context fields

func CInfo

func CInfo(ctx context.Context, msg string, fields ...zap.Field)

CInfo logs a message with context fields

func CWarn

func CWarn(ctx context.Context, msg string, fields ...zap.Field)

CWarn logs a message with context fields

func Debug

func Debug(msg string, fields ...zap.Field)

Debug logs a message at DebugLevel

func Debugf

func Debugf(template string, args ...interface{})

Debugf logs a message at DebugLevel with formatting

func Error

func Error(msg string, fields ...zap.Field)

Error logs a message at ErrorLevel

func Errorf

func Errorf(template string, args ...interface{})

Errorf logs a message at ErrorLevel with formatting

func Fatal

func Fatal(msg string, fields ...zap.Field)

Fatal logs a message at FatalLevel

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf logs a message at FatalLevel with formatting

func Info

func Info(msg string, fields ...zap.Field)

Info logs a message at InfoLevel

func Infof

func Infof(template string, args ...interface{})

Infof logs a message at InfoLevel with formatting

func Init

func Init(cfg *Config) error

Init initializes the global logger

func L

func L() *zap.Logger

L returns the global raw logger

func MaskEmail

func MaskEmail(email string) string

MaskEmail masks an email: hello@example.com -> h****@example.com

func MaskIDCard

func MaskIDCard(id string) string

MaskIDCard masks an ID card: 110101199001011234 -> 110***********1234

func MaskPhone

func MaskPhone(phone string) string

MaskPhone masks a phone number: 13812345678 -> 138****5678

func MaskSecret

func MaskSecret(secret string) string

MaskSecret completely hides a secret, showing only prefix/suffix hint if requested, or just generic mask. Default: ******

func MaskSecretWithPrefix

func MaskSecretWithPrefix(secret string) string

MaskSecretWithPrefix shows first 2 chars: "ab******"

func ReplaceGlobals

func ReplaceGlobals(logger *zap.Logger)

ReplaceGlobals replaces the global logger

func S

func S() *zap.SugaredLogger

S returns the global sugared logger

func Sync

func Sync()

Sync flushes any buffered log entries

func Warn

func Warn(msg string, fields ...zap.Field)

Warn logs a message at WarnLevel

func Warnf

func Warnf(template string, args ...interface{})

Warnf logs a message at WarnLevel with formatting

Types

type Config

type Config struct {
	Level          string
	Format         string
	OutputPaths    []string // For non-rotation outputs like stdout
	EnableRotation bool
	RotateLogPath  string
	MaxSize        int
	MaxBackups     int
	MaxAge         int
	Compress       bool
}

Init initializes the global logger For MVP, we stick to NewProduction or NewDevelopment based on a simple toggle, or just standard Production for now. Config defines log configuration

type ErrorWriter

type ErrorWriter struct{}

ErrorWriter writes to Error level

func NewGinErrorWriter

func NewGinErrorWriter() *ErrorWriter

NewGinErrorWriter returns an io.Writer that logs via zap Error

func (*ErrorWriter) Write

func (w *ErrorWriter) Write(p []byte) (n int, err error)

type Writer

type Writer struct {
	LogFunc func(msg string, fields ...interface{})
}

Writer is an io.Writer that writes to the zap logger

func NewGinWriter

func NewGinWriter() *Writer

NewGinWriter returns an io.Writer that logs via zap Info

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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