logx

package
v0.0.1-beta.5 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package logx 是 zap 的薄包装:业务代码只允许经本包取日志,禁止直接 import zap。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field = zap.Field

Field 是 zap.Field 的别名,业务代码通过 logx 构造器创建字段。

func Any

func Any(k string, v any) Field

func Bool

func Bool(k string, v bool) Field

func Duration

func Duration(k string, v time.Duration) Field

func Error

func Error(err error) Field

func Int

func Int(k string, v int) Field

func Int64

func Int64(k string, v int64) Field

func String

func String(k, v string) Field

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func New

func New(level, output string) (*Logger, error)

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...Field)

func (*Logger) DebugEnabled

func (l *Logger) DebugEnabled() bool

DebugEnabled level=debug 是否生效(accessLog 等 Debug 字段构造的 level 守卫 ——zap 的字段编码短路在调用内,字段切片已在调用点物化逃逸;热路径先判再 构造,level 恒定无双读风险)。zapcore 不泄露(内部判定)。

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...Field)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...Field)

func (*Logger) Sync

func (l *Logger) Sync() error

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...Field)

func (*Logger) With

func (l *Logger) With(fields ...Field) *Logger

Jump to

Keyboard shortcuts

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