Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(msg string, args ...any)
- func Debugf(format string, args ...any)
- func DisableDLPLogger()
- func DisableJsonLogger()
- func DisableTextLogger()
- func EnableDLPLogger()
- func EnableFormatters(formatters ...formatter.Formatter)
- func EnableJsonLogger()
- func EnableTextLogger()
- func Error(msg string, args ...any)
- func Errorf(format string, args ...any)
- func Fatal(msg string, args ...any)
- func Fatalf(format string, args ...any)
- func GetChanRecord(num ...uint16) chan slog.Record
- func GetSlogLogger() *slog.Logger
- func Info(msg string, args ...any)
- func Infof(format string, args ...any)
- func IsDLPEnabled() bool
- func New(handler Handler) *slog.Logger
- func NewConsoleHandler(w io.Writer, noColor bool, opts *slog.HandlerOptions) slog.Handler
- func NewJSONHandler(w io.Writer, opts *HandlerOptions) *slog.JSONHandler
- func NewOptions(options *slog.HandlerOptions) *slog.HandlerOptions
- func NewTextHandler(w io.Writer, opts *HandlerOptions) *slog.TextHandler
- func NewWriter(filename ...string) *writer
- func Printf(format string, args ...any)
- func Println(msg string, args ...any)
- func SetLevelDebug()
- func SetLevelError()
- func SetLevelFatal()
- func SetLevelInfo()
- func SetLevelTrace()
- func SetLevelWarn()
- func Trace(msg string, args ...any)
- func Tracef(format string, args ...any)
- func Warn(msg string, args ...any)
- func Warnf(format string, args ...any)
- type Attr
- func Any(key string, v any) Attr
- func Bool(key string, v bool) Attr
- func Duration(key string, v time.Duration) Attr
- func Float64(key string, v float64) Attr
- func Group(key string, args ...any) Attr
- func Int(key string, v int) Attr
- func Int64(key string, v int64) Attr
- func String(key string, v string) Attr
- func Time(key string, v time.Time) Attr
- func Uint64(key string, v uint64) Attr
- type Fields
- type Handler
- type HandlerOptions
- type Level
- type Logger
- func (l *Logger) Debug(msg string, args ...any)
- func (l *Logger) Debugf(format string, args ...any)
- func (l *Logger) Error(msg string, args ...any)
- func (l *Logger) Errorf(format string, args ...any)
- func (l *Logger) Fatal(msg string, args ...any)
- func (l *Logger) Fatalf(format string, args ...any)
- func (l *Logger) GetLevel() Level
- func (l *Logger) GetSlogLogger() *slog.Logger
- func (l *Logger) Info(msg string, args ...any)
- func (l *Logger) Infof(format string, args ...any)
- func (l *Logger) Printf(format string, args ...any)
- func (l *Logger) Println(msg string, args ...any)
- func (l *Logger) SetLevel(level Level) *Logger
- func (l *Logger) Trace(msg string, args ...any)
- func (l *Logger) Tracef(format string, args ...any)
- func (l *Logger) Warn(msg string, args ...any)
- func (l *Logger) Warnf(format string, args ...any)
- func (l *Logger) With(args ...any) *Logger
- func (l *Logger) WithContext(ctx context.Context) *Logger
- func (l *Logger) WithGroup(name string) *Logger
- func (l *Logger) WithValue(key string, val any) *Logger
- type Record
- type Value
Constants ¶
View Source
const ( TimeKey = slog.TimeKey LevelKey = slog.LevelKey MessageKey = slog.MessageKey SourceKey = slog.SourceKey )
View Source
const ( Name = "slog" Version = "v0.0.21" )
Variables ¶
View Source
var (
TimeFormat = "2006/01/02 15:04.05.000" // 默认时间格式
)
Functions ¶
func EnableFormatters ¶ added in v0.0.16
EnableFormatters 启用日志格式化器。
func GetChanRecord ¶ added in v0.0.15
GetChanRecord 使用通道获取日志信息
func GetSlogLogger ¶ added in v0.0.16
GetSlogLogger 返回原始log/slog的日志记录器
func NewConsoleHandler ¶ added in v0.0.2
NewConsoleHandler returns a log/slog.Handler using the receiver's options. Default options are used if opts is nil.
func NewJSONHandler ¶ added in v0.0.2
func NewJSONHandler(w io.Writer, opts *HandlerOptions) *slog.JSONHandler
func NewOptions ¶ added in v0.0.2
func NewOptions(options *slog.HandlerOptions) *slog.HandlerOptions
NewOptions 创建新的处理程序选项。
func NewTextHandler ¶ added in v0.0.2
func NewTextHandler(w io.Writer, opts *HandlerOptions) *slog.TextHandler
Types ¶
type Fields ¶ added in v0.0.18
type Fields struct {
// contains filtered or unexported fields
}
Fields 存储上下文字段
type HandlerOptions ¶ added in v0.0.2
type HandlerOptions = slog.HandlerOptions
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger 结构体定义,实现日志记录功能
func WithGroup ¶ added in v0.0.11
WithGroup 创建一个带有指定组名的全局日志记录器 这是一个包级别的便捷方法 参数:
- name: 日志组的名称
返回:
- 带有指定组名的新日志记录器实例
func (*Logger) GetSlogLogger ¶ added in v0.0.16
GetSlogLogger 方法
func (*Logger) WithContext ¶ added in v0.0.7
WithContext 使用给定的上下文
Source Files ¶
Click to show internal directories.
Click to hide internal directories.