diff --git a/lib/zap/zio/reader.go b/lib/zap/zio/reader.go index 1c65cc3cb9244179f140b3e589d33c5c9bf77f1c..3f0cbcfcc44b36b8da772c199e6ed54bbe7d578f 100644 --- a/lib/zap/zio/reader.go +++ b/lib/zap/zio/reader.go @@ -1,6 +1,7 @@ package zio import ( + "io" "time" "pggat2/lib/util/dio" @@ -9,12 +10,14 @@ import ( type Reader struct { reader dio.Reader + r io.Reader buf zap.Buf } func MakeReader(reader dio.Reader) Reader { return Reader{ reader: reader, + r: reader, } } @@ -23,15 +26,15 @@ func (T *Reader) SetReadDeadline(deadline time.Time) error { } func (T *Reader) ReadByte() (byte, error) { - return T.buf.ReadByte(T.reader) + return T.buf.ReadByte(T.r) } func (T *Reader) Read() (zap.In, error) { - return T.buf.Read(T.reader, true) + return T.buf.Read(T.r, true) } func (T *Reader) ReadUntyped() (zap.In, error) { - return T.buf.Read(T.reader, false) + return T.buf.Read(T.r, false) } var _ zap.Reader = (*Reader)(nil) diff --git a/lib/zap/zio/readwriter.go b/lib/zap/zio/readwriter.go index 7afe04c2c85310bf6962ebb71b27b033d69000f8..b5abf5ac4f2fc8ed8af0e91a99c143e55cf15323 100644 --- a/lib/zap/zio/readwriter.go +++ b/lib/zap/zio/readwriter.go @@ -1,6 +1,7 @@ package zio import ( + "io" "time" "pggat2/lib/util/dio" @@ -9,12 +10,16 @@ import ( type ReadWriter struct { rw dio.ReadWriter + r io.Reader + w io.Writer buf zap.Buf } func MakeReadWriter(rw dio.ReadWriter) ReadWriter { return ReadWriter{ rw: rw, + r: rw, + w: rw, } } @@ -31,19 +36,19 @@ func (T *ReadWriter) SetWriteDeadline(deadline time.Time) error { } func (T *ReadWriter) ReadByte() (byte, error) { - return T.buf.ReadByte(T.rw) + return T.buf.ReadByte(T.r) } func (T *ReadWriter) Read() (zap.In, error) { - return T.buf.Read(T.rw, true) + return T.buf.Read(T.r, true) } func (T *ReadWriter) ReadUntyped() (zap.In, error) { - return T.buf.Read(T.rw, false) + return T.buf.Read(T.r, false) } func (T *ReadWriter) WriteByte(b byte) error { - return T.buf.WriteByte(T.rw, b) + return T.buf.WriteByte(T.w, b) } func (T *ReadWriter) Write() zap.Out { diff --git a/lib/zap/zio/writer.go b/lib/zap/zio/writer.go index 3c2d616b4048ec5da91583f580fdb1cd6afceb52..1c283b7085f70159ba4c8048c3cc04935411e5e5 100644 --- a/lib/zap/zio/writer.go +++ b/lib/zap/zio/writer.go @@ -1,6 +1,7 @@ package zio import ( + "io" "time" "pggat2/lib/util/dio" @@ -9,12 +10,14 @@ import ( type Writer struct { writer dio.Writer + w io.Writer buf zap.Buf } func MakeWriter(writer dio.Writer) Writer { return Writer{ writer: writer, + w: writer, } } @@ -23,7 +26,7 @@ func (T *Writer) SetWriteDeadline(deadline time.Time) error { } func (T *Writer) WriteByte(b byte) error { - return T.buf.WriteByte(T.writer, b) + return T.buf.WriteByte(T.w, b) } func (T *Writer) Write() zap.Out {