mlog

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClearOpt

type ClearOpt struct {
	Clear  []string // 需要清理的日志类型,为空则清理所有类型
	Before int      // 删除几天之前的日志,默认为 7
}

ClearOpt: 清理选项

type Config

type Config struct {
	Path   string     // 日志存放路径
	Name   string     // 日志文件名前缀
	Level  slog.Level // 日志级别
	Stdout bool       // 是否同时输出到控制台
}

Config: 日志配置

type Logger

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

Logger: 日志对象

func New

func New(cfg Config) (l *Logger)

New: 创建 Logger 如果 Path/Name 未设置将使用默认值

func (*Logger) Clear

func (l *Logger) Clear(opt ClearOpt) (err error)

Clear: 清理日志文件(按文件名中日期)

func (*Logger) Close added in v0.4.6

func (l *Logger) Close() (err error)

Close: 关闭所有打开的日志文件

func (*Logger) Debug

func (l *Logger) Debug(msg string, kv ...any)

Debug: 记录 debug 日志

func (*Logger) Error

func (l *Logger) Error(msg string, kv ...any)

Error: 记录 error 日志

func (*Logger) Info

func (l *Logger) Info(msg string, kv ...any)

Info: 记录 info 日志

func (*Logger) Warn

func (l *Logger) Warn(msg string, kv ...any)

Warn: 记录 warn 日志

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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