gookit / slog

📑 Lightweight, configurable, extensible logging library written in Go. Support multi level, multi outputs and built-in multi file logger, buffers, clean, rotate-file handling.一个易于使用的,轻量级、可配置、可扩展的日志库。支持多个级别,输出到多文件;内置文件日志处理、自动切割、清理、压缩等增强功能
https://pkg.go.dev/github.com/gookit/slog
MIT License
396 stars 25 forks source link

请问日志的时间格式怎么添加毫秒输出 #79

Closed MapleLove2014 closed 2 years ago

inhere commented 2 years ago

可以设置 Formatter.TimeFormat, 如下:

slog.Configure(func(logger *slog.SugaredLogger) {
        f := logger.Formatter.(*slog.TextFormatter)
        // 追加 .000
        f.TimeFormat = "2006/01/02T15:04:05.000"
    })
MapleLove2014 commented 2 years ago

okok,多谢了