diff options
author | brb-g <45642843+brb-g@users.noreply.github.com> | 2019-08-29 11:27:49 -0700 |
---|---|---|
committer | Ian Lewis <ianlewis@google.com> | 2019-08-29 11:27:49 -0700 |
commit | 9ce9ceaf4e0678e06c5b899825f918b72f4d5889 (patch) | |
tree | 6c1f8eaf117ac59f3de2a169e4dd342ed1c97eab /vendor/github.com/sirupsen/logrus/writer.go | |
parent | 462bafb2e7a4d56b788a7467a9e7c05604f55a15 (diff) |
Replace pre-go1.11 vendoring with a go1.12 module. (#37)
Diffstat (limited to 'vendor/github.com/sirupsen/logrus/writer.go')
-rw-r--r-- | vendor/github.com/sirupsen/logrus/writer.go | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/vendor/github.com/sirupsen/logrus/writer.go b/vendor/github.com/sirupsen/logrus/writer.go deleted file mode 100644 index 7bdebedc6..000000000 --- a/vendor/github.com/sirupsen/logrus/writer.go +++ /dev/null @@ -1,62 +0,0 @@ -package logrus - -import ( - "bufio" - "io" - "runtime" -) - -func (logger *Logger) Writer() *io.PipeWriter { - return logger.WriterLevel(InfoLevel) -} - -func (logger *Logger) WriterLevel(level Level) *io.PipeWriter { - return NewEntry(logger).WriterLevel(level) -} - -func (entry *Entry) Writer() *io.PipeWriter { - return entry.WriterLevel(InfoLevel) -} - -func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { - reader, writer := io.Pipe() - - var printFunc func(args ...interface{}) - - switch level { - case DebugLevel: - printFunc = entry.Debug - case InfoLevel: - printFunc = entry.Info - case WarnLevel: - printFunc = entry.Warn - case ErrorLevel: - printFunc = entry.Error - case FatalLevel: - printFunc = entry.Fatal - case PanicLevel: - printFunc = entry.Panic - default: - printFunc = entry.Print - } - - go entry.writerScanner(reader, printFunc) - runtime.SetFinalizer(writer, writerFinalizer) - - return writer -} - -func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { - scanner := bufio.NewScanner(reader) - for scanner.Scan() { - printFunc(scanner.Text()) - } - if err := scanner.Err(); err != nil { - entry.Errorf("Error while reading from Writer: %s", err) - } - reader.Close() -} - -func writerFinalizer(writer *io.PipeWriter) { - writer.Close() -} |