a useful go log, support multiple writer.
- base logger
- console writer
- file writer
- log file rotate
- kafka writer (soon)
- sensitive information protection (soon)
The go version shall >= 1.16
go get -u -v github.com/legofun/go-log
import github.com/legofun/go-log
...
golog.SetupLog(golog.LogConfig{
Level: "debug",
Debug: false,
FullPath: true,
ConsoleWriter: golog.ConsoleWriterOptions{
Enable: true,
Color: true,
//Level: "abnormal",
},
FileWriter: golog.FileWriterOptions{
//Level: "",
Filename: "./test/golog-test-%Y%M%D%H%m.log",
Enable: true,
Rotate: true,
Daily: false,
Hourly: false,
Minutely: true,
//MaxDays: 0,
//MaxHours: 0,
//MaxMinutes: 0,
},
})
golog.Debug("this is debug log")
golog.Common("this is common log")
golog.Abnormal("this is abnormal log")
golog.Transaction("this is transaction log")
golog.Error("this is error log")
golog.Access("this is access log")
Use of go-log is governed by the MIT License