Little helper to run CNCF's k3s in Docker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
k3d/vendor/github.com/sirupsen/logrus/hooks/writer
Jacob Weinstock fdd5e5a57a log to stdout or stderr depending on the log level 4 years ago
..
README.md log to stdout or stderr depending on the log level 4 years ago
writer.go log to stdout or stderr depending on the log level 4 years ago

README.md

Writer Hooks for Logrus

Send logs of given levels to any object with io.Writer interface.

Usage

If you want for example send high level logs to Stderr and logs of normal execution to Stdout, you could do it like this:

package main

import (
	"io/ioutil"
	"os"

	log "github.com/sirupsen/logrus"
	"github.com/sirupsen/logrus/hooks/writer"
)

func main() {
	log.SetOutput(ioutil.Discard) // Send all logs to nowhere by default

	log.AddHook(&writer.Hook{ // Send logs with level higher than warning to stderr
		Writer: os.Stderr,
		LogLevels: []log.Level{
			log.PanicLevel,
			log.FatalLevel,
			log.ErrorLevel,
			log.WarnLevel,
		},
	})
	log.AddHook(&writer.Hook{ // Send info and debug logs to stdout
		Writer: os.Stdout,
		LogLevels: []log.Level{
			log.InfoLevel,
			log.DebugLevel,
		},
	})
	log.Info("This will go to stdout")
	log.Warn("This will go to stderr")
}