Go-Log
Go-Log is a utility log package built to customize the Go's normal log package. Prominent features are
- Tag the logs into debug and error variant.
- Add/Remove Timestamp to logs
- Get the calling function details in logs
- Synchronized with mutex locks to handle multiple logging
Install
go get github.com/MindorksOpenSource/Go-Log
Import
import (
"github.com/MindorksOpenSource/Go-Log"
)
Examples
1. GoLog Debug
func main() {
golog.D("A basic primitive debug log.")
}
This golog prints the message without any extra information like:
$ A basic primitive debug log.
2. GoLog Error
func main() {
golog.E("This a basic primitive error log.")
}
This golog prints the message while tagging it as an ERROR like:
$ [ERROR] This a basic primitive error log.
// Adds time to the log
golog.ConfigureTimer()
// Adds the calling function path to log
golog.ConfigureCallingFunction()
3. GoLog Debug/Error with Time
func main() {
golog.ConfigureTimer()
golog.D("A debug log with time")
}
This golog prints the message with its timestamp like:
$ 2018/10/29 15:52:24 A debug log with time
4. GoLog Debug/Error with CallingFunction
func main() {
golog.ConfigureCallingFunction()
golog.D("A debug log with calling function")
}
This golog prints the message with its timestamp like:
$ [main.main] A debug log with calling function
You can use both the configurations together also. Go gophers!
Contributor
Yashish Dua
Show some ❤