zlogtime is a logging library, which measure the elapsed time of services on-demand.
go get -u github.com/owlsome-official/zlogtime
var timeTracker zlogtime.ZLogTime = zlogtime.New()
or with configuration
var timeTrackerWithConfig zlogtime.ZLogTime = zlogtime.New(
zlogtime.Config{
LogLevel: zerolog.DebugLevel.String()
}
)
// Step 1: Defined as global (tools) variable
var (
timeTracker zlogtime.ZLogTime = zlogtime.New()
)
// Step 2: Call TimeTrack within a function
func FuncName() {
// NOTE: Always used with "defer"
defer timeTracker.TimeTrack("NAME", time.Now())
...
}
type Config struct {
// Optional. Default: false
Hidden bool
// Optional. Default: "info"
LogLevel string
// Optional. Default: "milli". Possible Value: ["nano", "micro", "milli"]
ElapsedTimeUnit string
}
var ConfigDefault = Config{
Hidden: false,
LogLevel: "info",
ElapsedTimeUnit: "milli",
}
Please go to example/main.go
Made with ❤️ by watsize