]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/stats.go
Language mistakes and stylistic fixes
[govpn.git] / src / cypherpunks.ru / govpn / stats.go
index 757eb55676fbc7eacba078a0f161ab21903eb2cf..91cbf5dfb20c2a9ad7cfb933cae5350d4de8490d 100644 (file)
@@ -46,45 +46,52 @@ func StatsProcessor(stats string, peers *KnownPeers) {
                "port":    stats,
        }
 
-       logger.WithFields(fields).WithField(
+       logger.WithFields(
+               fields,
+       ).WithField(
                "port", stats,
        ).Debug("Stats are going to listen")
        statsPort, err := net.Listen("tcp", stats)
        if err != nil {
                logger.WithError(err).WithField(
                        "stats", stats,
-               ).Error("Can't listen stats server")
+               ).Error("Can not listen stats server")
                return
        }
 
        for {
                conn, err = statsPort.Accept()
                if err != nil {
-                       logger.WithFields(fields).WithError(err).Error("Couldn't accept connection")
+                       logger.WithFields(fields).WithError(err).Error("Can not accept connection")
                        continue
                }
                deadLine := time.Now().Add(rwTimeout)
                if err = conn.SetDeadline(deadLine); err != nil {
-                       logger.WithFields(fields).WithField(
-                               "deadline", deadLine.String(),
-                       ).WithError(err).Error("Can't set deadline")
+                       logger.WithFields(
+                               fields,
+                       ).WithField(
+                               "deadline",
+                               deadLine.String(),
+                       ).WithError(err).Error("Can not set deadline")
                } else if _, err = conn.Read(buf); err != nil {
-                       logger.WithFields(fields).WithError(err).Error("Couldn't read buffer")
+                       logger.WithFields(fields).WithError(err).Error("Can not read buffer")
                } else if _, err = conn.Write([]byte("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\n\r\n")); err != nil {
-                       logger.WithFields(fields).WithError(err).Error("Couldn't write HTTP headers")
+                       logger.WithFields(fields).WithError(err).Error("Can not write HTTP headers")
                } else {
                        var peersList []*Peer
                        for _, peer := range *peers {
                                peersList = append(peersList, *peer)
                        }
                        if err = json.NewEncoder(conn).Encode(peersList); err != nil {
-                               logger.WithFields(fields).WithField(
+                               logger.WithFields(
+                                       fields,
+                               ).WithField(
                                        "peers", len(peersList),
-                               ).WithError(err).Error("Can't encode to JSON")
+                               ).WithError(err).Error("Can not encode to JSON")
                        }
                }
                if err = conn.Close(); err != nil {
-                       logger.WithFields(fields).WithError(err).Error("Couldn't close connection")
+                       logger.WithFields(fields).WithError(err).Error("Can not close connection")
                }
        }
 }