Skip to content

ms-xy/logtools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

logtools

This go package is a wrapper package for the amazing logrus logging package. It provides an Initialize() function that is called automatically on first use. The initializer sets a sane default log formatter. Currently the implemenation defaults to setting the loglevel to debug. If you don't like this, then call Initialize() explizitly and afterwards set the logging level yourself by using SetLevel(InfoLevel) (or whichever level you want).

Usage

go get github.com/ms-xy/logtools
import (
  "github.com/ms-xy/logtools"
)

func main() {
  logtools.Info("Some informative log message")
  logtools.WithFields(logtools.Fields{
    "key": "value",
  }).Warn("More informative with the WithFields Wrapper of logrus")
}

To set the loglevel explicitly:

func main() {
  logtools.Initialize()
  logtools.SetLevel(logtools.WarnLevel)
  logtools.Info("Some informative log message") // <- does not print anymore
  logtools.WithFields(logtools.Fields{
    "key": "value",
  }).Warn("More informative with the WithFields Wrapper of logrus")
}

License

MIT - just as the logrus package.

About

Wrapper around the amazing logrus go package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages