log

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	*slog.Logger
	*handler.Handler
}

func NewLogger

func NewLogger(opts ...Option) *Logger

func (*Logger) Error

func (h *Logger) Error(ctx context.Context, s string, i ...interface{})

func (*Logger) Info

func (h *Logger) Info(ctx context.Context, s string, i ...any)

func (*Logger) Log

func (h *Logger) Log(level log.Level, keyAndValues ...any) error

func (*Logger) LogMode

func (h *Logger) LogMode(_ logger.LogLevel) logger.Interface

func (*Logger) Trace

func (h *Logger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (*Logger) Warn

func (h *Logger) Warn(ctx context.Context, s string, i ...interface{})

type Option

type Option interface {
	Apply(*Options)
}

func WithLevel

func WithLevel(level slog.Level) Option

func WithTimeFormat

func WithTimeFormat(format string) Option

func WithWriter

func WithWriter(writer io.Writer) Option

type Options

type Options struct {
	Level      slog.Level // 日志级别
	Writer     io.Writer  // 日志输出
	TimeFormat string     // 时间格式
}

Directories

Path Synopsis
Package tint 实现了一个 [slog.Handler],可以写入着色(colorized)的日志。
Package tint 实现了一个 [slog.Handler],可以写入着色(colorized)的日志。

Jump to

Keyboard shortcuts

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