Based on the standard log
library with minimum dependencies.
Just like other go packages, use: go get https://github.com/ImanHz/go-tinylogger
- Create a new logger instance with New()
- Set the logger output color is SetColor(bool onOff) (default:true, i.e: use color)
- Simply use on of the Info(v ...any), Warning(v ...any), Error(v ...any) and Panic(code int, v ...any) functions to log to
stdout
. Panic will terminate the program with exitcode
- Use Pretty(v any) to display
struct
,slice
ormap
data structures in a pretty manner
package main
import gotinylogger "github.com/ImanHz/go-tinylogger"
func main() {
// obtain a new instance
log := gotinylogger.New()
log.Info("Info")
log.Warning("Warning")
log.Error("Error")
log.Pretty("pretty sample", []string{"first", "second"})
log.SetColor(false)
log.Info("no color :(")
log.Panic(1, "panic!")
}
Run: go run main.go