log

package
v0.0.0-...-dc62a57 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConsoleFormat = "console"
	JsonFormat    = "json"
)

Variables

This section is empty.

Functions

func Ctx

func DPanic

func DPanic(msg string, fields ...zapcore.Field)

func DPanicContext

func DPanicContext(ctx context.Context, msg string, fields ...zapcore.Field)

func DPanicf

func DPanicf(format string, v ...interface{})

func DPanicfContext

func DPanicfContext(ctx context.Context, format string, v ...interface{})

func DPanicln

func DPanicln(args ...interface{})

func DPanicw

func DPanicw(format string, v ...interface{})

func DPanicwContext

func DPanicwContext(ctx context.Context, format string, v ...interface{})

func Debug

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

func DebugContext

func DebugContext(ctx context.Context, msg string, fields ...zapcore.Field)

func Debugf

func Debugf(format string, v ...interface{})

func DebugfContext

func DebugfContext(ctx context.Context, format string, v ...interface{})

func Debugln

func Debugln(args ...interface{})

func Debugw

func Debugw(format string, v ...interface{})

func DebugwContext

func DebugwContext(ctx context.Context, format string, v ...interface{})

func Error

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

func ErrorContext

func ErrorContext(ctx context.Context, msg string, fields ...zapcore.Field)

func Errorf

func Errorf(format string, v ...interface{})

func ErrorfContext

func ErrorfContext(ctx context.Context, format string, v ...interface{})

func Errorln

func Errorln(args ...interface{})

func Errorw

func Errorw(format string, v ...interface{})

func ErrorwContext

func ErrorwContext(ctx context.Context, format string, v ...interface{})

func Fatal

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

func FatalContext

func FatalContext(ctx context.Context, msg string, fields ...zapcore.Field)

func Fatalf

func Fatalf(format string, v ...interface{})

func FatalfContext

func FatalfContext(ctx context.Context, format string, v ...interface{})

func Fatalln

func Fatalln(args ...interface{})

func Fatalw

func Fatalw(format string, v ...interface{})

func FatalwContext

func FatalwContext(ctx context.Context, format string, v ...interface{})

func Flush

func Flush()

func Info

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

func InfoContext

func InfoContext(ctx context.Context, msg string, fields ...zapcore.Field)

func Infof

func Infof(format string, v ...interface{})

func InfofContext

func InfofContext(ctx context.Context, format string, v ...interface{})

func Infoln

func Infoln(args ...interface{})

func Infow

func Infow(format string, v ...interface{})

func InfowContext

func InfowContext(ctx context.Context, format string, v ...interface{})

func L

func L() *otelzap.Logger

func Logger

func Logger() *otelzap.Logger

func MustNewLogger

func MustNewLogger(opts ...OptionFunc) *zap.Logger

func MustNewOtelLogger

func MustNewOtelLogger(opts ...OptionFunc) *otelzap.Logger

func Panic

func Panic(msg string, fields ...zapcore.Field)

func PanicContext

func PanicContext(ctx context.Context, msg string, fields ...zapcore.Field)

func Panicf

func Panicf(format string, v ...interface{})

func PanicfContext

func PanicfContext(ctx context.Context, format string, v ...interface{})

func Panicln

func Panicln(args ...interface{})

func Panicw

func Panicw(format string, v ...interface{})

func PanicwContext

func PanicwContext(ctx context.Context, format string, v ...interface{})

func S

func Sugar

func Sugar() *otelzap.SugaredLogger

func Warn

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

func WarnContext

func WarnContext(ctx context.Context, msg string, fields ...zapcore.Field)

func Warnf

func Warnf(format string, v ...interface{})

func WarnfContext

func WarnfContext(ctx context.Context, format string, v ...interface{})

func Warnln

func Warnln(args ...interface{})

func Warnw

func Warnw(format string, v ...interface{})

func WarnwContext

func WarnwContext(ctx context.Context, format string, v ...interface{})

Types

type GormLogger

type GormLogger struct {
	Logger *otelzap.Logger
}

func MustNewGormLogger

func MustNewGormLogger(l *otelzap.Logger) *GormLogger

func (GormLogger) Error

func (g GormLogger) Error(ctx context.Context, s string, i ...interface{})

func (GormLogger) Info

func (g GormLogger) Info(ctx context.Context, s string, i ...interface{})

func (GormLogger) LogMode

func (g GormLogger) LogMode(_ logger.LogLevel) logger.Interface

func (GormLogger) Trace

func (g GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (GormLogger) Warn

func (g GormLogger) Warn(ctx context.Context, s string, i ...interface{})

type OptionFunc

type OptionFunc func(o *Options)

func WithColor

func WithColor(on bool) OptionFunc

默认不开启彩色打印

func WithDevelopmentLogging

func WithDevelopmentLogging(on bool) OptionFunc

创建一个development级别的日志(日志将打印更多信息)

func WithErrLevel

func WithErrLevel(lvl zapcore.Level) OptionFunc

设置被认为错误的日志级别,默认的ErrorLevel为Info级别

func WithErrOutPaths

func WithErrOutPaths(path ...string) OptionFunc

如果使用该函数且path.len>=1,则将不自动使用stderr,除非在path中添加stderr 如果path.len==0或不使用该函数则默认日志输出在stderr中

func WithFormat

func WithFormat(format string) OptionFunc

如果format格式错误或默认则使用console,可选"console"以及"json"

func WithLevel

func WithLevel(lvl zapcore.Level) OptionFunc

默认的Level为Info级别

func WithOtelZapOptions

func WithOtelZapOptions(opt ...otelzap.Option) OptionFunc

允许创建时使用otelzap自带的Options

func WithOutputPaths

func WithOutputPaths(path ...string) OptionFunc

如果使用该函数且path.len>=1,则将不自动使用stdout,除非在path中添加stdout 如果path.len==0或不使用该函数则默认日志输出在stdout中

func WithZapOptions

func WithZapOptions(opt ...zap.Option) OptionFunc

允许创建时使用zap自带的Options

type Options

type Options struct {
	OutputPaths      []string      `json:"output-paths"       mapstructure:"output-paths"`
	ErrorOutputPaths []string      `json:"error-output-paths" mapstructure:"error-output-paths"`
	Level            zapcore.Level `json:"level"              mapstructure:"level"`
	ErrorLevel       zapcore.Level `json:"error-level"              mapstructure:"error-level"`
	Format           string        `json:"format"             mapstructure:"format"`
	EnableColor      bool          `json:"enable-color"       mapstructure:"enable-color"`
	Development      bool          `json:"development"        mapstructure:"development"`
	ZapOptions       []zap.Option
	OtelZapOptions   []otelzap.Option
}

Jump to

Keyboard shortcuts

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