Skip to content

Commit

Permalink
Merge pull request #180 from pixlise/bug/quant
Browse files Browse the repository at this point in the history
Better log msgs for WS connection/data import
  • Loading branch information
pnemere authored Mar 15, 2024
2 parents 6b515f1 + 84efc42 commit c0933bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions api/dataimport/internal/converterSelector/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package converterSelector

import (
"errors"
"fmt"
"path/filepath"
"strings"

Expand Down Expand Up @@ -85,10 +86,12 @@ func SelectDataConverter(localFS fileaccess.FileAccess, remoteFS fileaccess.File
}

// Log the paths to help us diagnose issues...
log.Infof("SelectDataConverter path listing:")
// Print it in one log message
logMsg := "SelectDataConverter path listing:"
for c, item := range items {
log.Infof(" %v. %v", c+1, item)
logMsg += fmt.Sprintf("\n %v. %v\n", c+1, item)
}
log.Infof(logMsg)

// Unknown
return nil, errors.New("Failed to determine dataset type to import.")
Expand Down
6 changes: 3 additions & 3 deletions api/ws/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func MakeWSHandler(m *melody.Melody, svcs *services.APIServices) *WSHandler {
}

func (ws *WSHandler) clearOldTokens() {
nowSec := time.Now().Unix() // TODO: use GetTimeNowSec
nowSec := ws.svcs.TimeStamper.GetTimeNowSec()
for token, usr := range ws.connectTokens {
if usr.expiryUnixSec < nowSec {
delete(ws.connectTokens, token)
Expand All @@ -48,7 +48,7 @@ func (ws *WSHandler) HandleBeginWSConnection(params apiRouter.ApiHandlerGenericP
// Generate a token that is valid for a short time
token := utils.RandStringBytesMaskImpr(32)

expirySec := time.Now().Unix() + 10 // TODO: use GetTimeNowSec
expirySec := ws.svcs.TimeStamper.GetTimeNowSec() + 10

// Clear out old ones, now is a good a time as any!
ws.clearOldTokens()
Expand Down Expand Up @@ -90,7 +90,7 @@ func (ws *WSHandler) HandleConnect(s *melody.Session) {
}

if conn, ok := ws.connectTokens[token[0]]; !ok {
fmt.Printf("WS connect failed for INVALID token: %v\n", token)
fmt.Printf("WS connect failed for UNKNOWN token: %v\n", token)
s.CloseWithMsg([]byte("Invalid token"))
return
} else {
Expand Down

0 comments on commit c0933bd

Please sign in to comment.