A very simple logger for debugging purposes.
Make sure you have setup Go in your environtment
go get github.com/gujarats/logger
It is very simple you can just call it :
logger.Debug("prefix :: ", "Hello World logger")
logger.Debug("prefix2 :: ", "testing")
logger.Debug("prefix3 :: ", "foo bar")
This will output
That's it. it would print the log message with specific format time. And save it to a logger,log
file.
If you want to ouput the log to a file simple just add this function to your func init
:
func init(
...
logger.DebugToFile()
...
)
You can also set color as you like :
func init() {
debugStyle := logger.DebugStyle{
PrefixColor: logger.Yellow,
MessageColor: logger.Blue,
Style: logger.Underline,
}
timeStyle := logger.TimeStyle{
YearColor: logger.White,
SepColor: logger.Yellow,
DateColor: logger.Cyan,
Style: logger.Italic,
}
logger.NewCustomColor(debugStyle, timeStyle)
}
// you can call it anywhere direcly
logger.Debug("prefix :: ", "Hello World logger")