mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Preliminary debug state
This commit is contained in:
+6
-2
@@ -18,14 +18,14 @@ type LogReadWriteCloserWithAddr struct {
|
||||
// Read reads from connection
|
||||
func (l *LogReadWriteCloserWithAddr) Read(p []byte) (n int, err error) {
|
||||
n, err = l.conn.Read(p)
|
||||
l.logger.Debugw("Finish reading", "name", l.name, "socketid", l.sockid, "nbytes", n, "error", err)
|
||||
l.logger.Debugw("Finish reading", "name", l.name, "socketid", l.sockid, "nbytes", n, "error", err, "localAddr", l.LocalAddr())
|
||||
return
|
||||
}
|
||||
|
||||
// Write writes into connection.
|
||||
func (l *LogReadWriteCloserWithAddr) Write(p []byte) (n int, err error) {
|
||||
n, err = l.conn.Write(p)
|
||||
l.logger.Debugw("Finish writing", "name", l.name, "socketid", l.sockid, "nbytes", n, "error", err)
|
||||
l.logger.Debugw("Finish writing", "name", l.name, "socketid", l.sockid, "nbytes", n, "error", err, "localAddr", l.LocalAddr())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ func (l *LogReadWriteCloserWithAddr) RemoteAddr() *net.TCPAddr {
|
||||
return l.conn.RemoteAddr()
|
||||
}
|
||||
|
||||
func (l *LogReadWriteCloserWithAddr) SocketID() string {
|
||||
return l.sockid
|
||||
}
|
||||
|
||||
// NewLogRWC wraps ReadWriteCloser with logger calls.
|
||||
func NewLogRWC(conn ReadWriteCloserWithAddr, logger *zap.SugaredLogger, sockid string, name string) ReadWriteCloserWithAddr {
|
||||
return &LogReadWriteCloserWithAddr{
|
||||
|
||||
Reference in New Issue
Block a user