From ef3283638a7c46a0a3f752d62bb19ff0dd4df8b8 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Tue, 11 Dec 2018 21:19:57 +0100 Subject: [PATCH] logger: add stderrlogger (sometimes useful) --- logger/stderrlogger.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 logger/stderrlogger.go diff --git a/logger/stderrlogger.go b/logger/stderrlogger.go new file mode 100644 index 0000000..6ca0aad --- /dev/null +++ b/logger/stderrlogger.go @@ -0,0 +1,27 @@ +package logger + +import ( + "fmt" + "os" +) + +type stderrLogger struct { + Logger +} + +type stderrLoggerOutlet struct {} + +func (stderrLoggerOutlet) WriteEntry(entry Entry) error { + fmt.Fprintf(os.Stderr, "%#v\n", entry) + return nil +} + +var _ Logger = testLogger{} + +func NewStderrDebugLogger() Logger { + outlets := NewOutlets() + outlets.Add(&stderrLoggerOutlet{}, Debug) + return &testLogger{ + Logger: NewLogger(outlets, 0), + } +}