Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 609 Bytes

README.md

File metadata and controls

30 lines (22 loc) · 609 Bytes

go-loggerger

package main

import "github.com/daneshvar/go-logger"

func main() {
	defer logger.Close()
	logger.RedirectStdLog()

	consoleEnabler := func(l logger.Level, s string) bool { return true }
	stackEnabler := func(l logger.Level, s string) bool { return l == logger.ErrorLevel }
	logger.Config(logger.ConsoleWriter(true, stackEnabler, consoleEnabler))

	log := logger.GetLogger("example")

	log.Warn("Not Found config file")

	log.Infov("GET",
		"url", "http://example.com/data.json",
	)

	log.Error("Fetch",
		"url", "http://example.com",
		"attempt", 3,
		"backoff", time.Second,
	)
}