Can not change to customization format Template
tonyho opened this issue · comments
TonyHo commented
System (please complete the following information):
- OS:
Windows 10 X64
- GO Version:
1.18
- Pkg Version:
don't know, I use the go get to use the code
Describe the bug
Customization template is not taken for printing.
To Reproduce
import log "github.com/gookit/slog"
const simplestTemplate = "[{{datetime}}] [{{level}}] {{message}} {{data}} {{extra}}"
func init() {
log.GetFormatter().(*log.TextFormatter).Template = simplestTemplate
log.SetLogLevel(log.ErrorLevel)
log.Errorf("Test\n")
}
func main() {
}
Expected behavior
I think it should output the following log:
[2022/05/18T17:20:39] [ERROR] Test
While, it outputs:
[2022/05/18T17:20:39] [application] [ERROR] [proc.go:6222,doInit] Test
Inhere commented
A bug has been fixed, version v0.3.1.
Please upgrade to the latest version.
The README has an error and should use SetTemplate()
const simplestTemplate = "[{{datetime}}] [{{level}}] {{message}} {{data}} {{extra}}"
log.GetFormatter().(*log.TextFormatter).SetTemplate(simplestTemplate)
TonyHo commented
Fix verified. Thanks for the lighting speed fix.