Logo

0x5a.live

for different kinds of informations and explorations.

GitHub - cabify/logrusiowriter: io.Writer implementation using logrus logger [managed by soy-programador]

io.Writer implementation using logrus logger [managed by soy-programador] - cabify/logrusiowriter

Visit SiteGitHub - cabify/logrusiowriter: io.Writer implementation using logrus logger [managed by soy-programador]

GitHub - cabify/logrusiowriter: io.Writer implementation using logrus logger [managed by soy-programador]

io.Writer implementation using logrus logger [managed by soy-programador] - cabify/logrusiowriter

Powered by 0x5a.live ๐Ÿ’—

logrusiowriter

io.Writer implementation using logrus

Travis CI build status GoDoc Coverage Status Mentioned in Awesome Go

Motivation

Many golang libraries use the golang's log package to print their logs. This means that if your application uses logrus to print structured logging, those packages will print a format that is (probably) incompatible with yours, and you may end losing logs in your logs collector because they can't be parsed properly.

Solution

Print the logs written using log.Printf through logrus, by setting log.SetOutput to an io.Writer implementation that uses logrus as output, i.e.:

	log.SetOutput(logrusiowriter.New())

See example_*_test.go files to find testable examples that serve as documentation.

Simple solution

Or... you can simply use the standard APIs that logrus provides, i.e., this does the same as this package:

    log.SetOutput(logrus.WithFields(logrus.Fields{"logger": "stdlib"}).WriterLevel(logrus.InfoLevel))

So, unless you want this to be configurable using an envconfig-filled struct, there's no reason to use this library.

GoLang Resources

are all listed below.

Resources

listed to get explored on!!

Made with โค๏ธ

to provide different kinds of informations and resources.