| 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{}) |
| go entry.writerScanner(reader, printFunc) |
| runtime.SetFinalizer(writer, writerFinalizer) |
| func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { |
| scanner := bufio.NewScanner(reader) |
| printFunc(scanner.Text()) |
| if err := scanner.Err(); err != nil { |
| entry.Errorf("Error while reading from Writer: %s", err) |
| func writerFinalizer(writer *io.PipeWriter) { |