[DOC] typos
This commit is contained in:
parent
5736ff3d97
commit
bda7df2362
|
@ -1,5 +1,5 @@
|
||||||
// reciever of log entry over network (websocket)
|
// receiver of log entry over network (websocket)
|
||||||
package recieve
|
package receive
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
@ -38,21 +38,21 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
var maybeToken string
|
var maybeToken string
|
||||||
msgType, msg, err := c.ReadMessage()
|
msgType, msg, err := c.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logEntry.Error("recieving token", err)
|
logEntry.Error("receiving token", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if msgType != websocket.TextMessage {
|
if msgType != websocket.TextMessage {
|
||||||
logEntry.Warn("recieve no token")
|
logEntry.Warn("receive no token")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
maybeToken = string(msg)
|
maybeToken = string(msg)
|
||||||
logEntry.AddField("token", maybeToken)
|
logEntry.AddField("token", maybeToken)
|
||||||
if !database.IsTokenValid(maybeToken) {
|
if !database.IsTokenValid(maybeToken) {
|
||||||
logEntry.Warn("recieve wrong token")
|
logEntry.Warn("receive wrong token")
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
token = maybeToken
|
token = maybeToken
|
||||||
logEntry.Info("recieve valid token")
|
logEntry.Info("receive valid token")
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logEntry.Error("recieving log entry:", err)
|
logEntry.Error("receiving log entry:", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(msg, &entry)
|
err = json.Unmarshal(msg, &entry)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
package recieve
|
package receive
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/genofire/logmania/api/recieve"
|
"github.com/genofire/logmania/api/receive"
|
||||||
"github.com/genofire/logmania/database"
|
"github.com/genofire/logmania/database"
|
||||||
"github.com/genofire/logmania/lib"
|
"github.com/genofire/logmania/lib"
|
||||||
"github.com/genofire/logmania/log"
|
"github.com/genofire/logmania/log"
|
||||||
|
@ -53,7 +53,7 @@ func main() {
|
||||||
|
|
||||||
api = &lib.HTTPServer{
|
api = &lib.HTTPServer{
|
||||||
Addr: config.API.Bind,
|
Addr: config.API.Bind,
|
||||||
Handler: recieve.NewHandler(),
|
Handler: receive.NewHandler(),
|
||||||
}
|
}
|
||||||
api.Start()
|
api.Start()
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
type SelfLogger struct {
|
type SelfLogger struct {
|
||||||
log.Logger
|
log.Logger
|
||||||
AboveLevel log.LogLevel
|
AboveLevel log.LogLevel
|
||||||
lastMsg string
|
lastMsg string
|
||||||
lastTime int
|
lastTime int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSelfLogger() *SelfLogger {
|
func NewSelfLogger() *SelfLogger {
|
||||||
|
@ -26,15 +26,14 @@ func (l *SelfLogger) Hook(e *log.Entry) {
|
||||||
if l.lastTime > 15 {
|
if l.lastTime > 15 {
|
||||||
panic("selflogger same log to oftern")
|
panic("selflogger same log to oftern")
|
||||||
}
|
}
|
||||||
if l.lastMsg == e.Text{
|
if l.lastMsg == e.Text {
|
||||||
l.lastTime += 1
|
l.lastTime += 1
|
||||||
} else {
|
} else {
|
||||||
l.lastMsg = e.Text
|
l.lastMsg = e.Text
|
||||||
l.lastTime = 1
|
l.lastTime = 1
|
||||||
}
|
}
|
||||||
database.InsertEntry("",e)
|
database.InsertEntry("", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (l *SelfLogger) Close() {
|
func (l *SelfLogger) Close() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue