Merge pull request #598 from nspcc-dev/loging-fixes

Logging fixes
This commit is contained in:
Vsevolod 2020-01-13 17:37:06 +03:00 committed by GitHub
commit fe7cca7cc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 16 deletions

View file

@ -134,6 +134,7 @@ func handleLoggingParams(ctx *cli.Context, cfg config.ApplicationConfiguration)
cc.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder cc.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
cc.Encoding = "console" cc.Encoding = "console"
cc.Level = zap.NewAtomicLevelAt(level) cc.Level = zap.NewAtomicLevelAt(level)
cc.Sampling = nil
if logPath := cfg.LogPath; logPath != "" { if logPath := cfg.LogPath; logPath != "" {
if err := io.MakeDirForFile(logPath, "logger"); err != nil { if err := io.MakeDirForFile(logPath, "logger"); err != nil {

View file

@ -82,22 +82,22 @@ func (t *TCPTransport) handleConn(conn net.Conn) {
t.server.register <- p t.server.register <- p
// When a new peer is connected we send out our version immediately. // When a new peer is connected we send out our version immediately.
if err := t.server.sendVersion(p); err != nil { err = t.server.sendVersion(p)
t.log.Error("error on sendVersion", zap.Stringer("addr", p.RemoteAddr()), zap.Error(err)) if err == nil {
} r := io.NewBinReaderFromIO(p.conn)
r := io.NewBinReaderFromIO(p.conn) for {
for { msg := &Message{}
msg := &Message{} err = msg.Decode(r)
err = msg.Decode(r)
if err == payload.ErrTooManyHeaders { if err == payload.ErrTooManyHeaders {
t.log.Warn("not all headers were processed") t.log.Warn("not all headers were processed")
r.Err = nil r.Err = nil
} else if err != nil { } else if err != nil {
break break
} }
if err = t.server.handleMessage(p, msg); err != nil { if err = t.server.handleMessage(p, msg); err != nil {
break break
}
} }
} }
t.server.unregister <- peerDrop{p, err} t.server.unregister <- peerDrop{p, err}

View file

@ -99,7 +99,7 @@ func (s *Server) requestHandler(w http.ResponseWriter, httpRequest *http.Request
} }
func (s *Server) methodHandler(w http.ResponseWriter, req *Request, reqParams Params) { func (s *Server) methodHandler(w http.ResponseWriter, req *Request, reqParams Params) {
s.log.Info("processing rpc request", s.log.Debug("processing rpc request",
zap.String("method", req.Method), zap.String("method", req.Method),
zap.String("params", fmt.Sprintf("%v", reqParams))) zap.String("params", fmt.Sprintf("%v", reqParams)))