logs is a Go logs manager. It can use many logs adapters.
go get github.com/ha666/logs
As of now this logs support console, file .
First you must import it
import (
"github.com/ha666/logs"
)
Then init a Log (example with console adapter)
logs.SetLogger(logs.AdapterConsole, `{"level":7}`)
the first params stand for how many channel
Use it like this:
logs.Alert("alert")
logs.Error("error")
logs.Warning("warning")
logs.Warn("warn")
logs.Info("info")
logs.Debug("debug")
logs.Trace("trace")
Configure file adapter like this:
logs.SetLogger(logs.AdapterFile, `{"filename":"./log/log.log","level":7,"maxlines":0,"maxsize":0,"daily":true,"maxdays":100}`)
The module can be configured to include the file & line number of the log calls in the logging output. This functionality is disabled by default, but can be enabled using the following code:
logs.EnableFuncCallDepth(true)
Use true to turn file & line number logging on, and false to turn it off. Default is false.
If your application encapsulates the call to the log methods, you may need use SetLogFuncCallDepth to set the number of stack frames to be skipped before the caller information is retrieved. The default is 2.
logs.SetLogFuncCallDepth(3)