Reduce graphql-middleware and graphql-server logs (#18738)

This commit is contained in:
Gustavo Trott 2023-09-07 11:54:27 -03:00 committed by GitHub
parent b8eade7735
commit 047eccdd92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 19 additions and 16 deletions

View File

@ -29,7 +29,7 @@ func HasuraClient(browserConnection *common.BrowserConnection, cookies []*http.C
hasuraConnectionId := "HC" + fmt.Sprintf("%010d", lastHasuraConnectionId)
log = log.WithField("hasuraConnectionId", hasuraConnectionId)
defer log.Infof("finished")
defer log.Debugf("finished")
// Add sub-protocol
var dialOptions websocket.DialOptions
@ -80,7 +80,7 @@ func HasuraClient(browserConnection *common.BrowserConnection, cookies []*http.C
thisConnection.Websocket = c
// Log the connection success
log.Infof("connected with Hasura")
log.Debugf("connected with Hasura")
// Configure the wait group
var wg sync.WaitGroup

View File

@ -16,7 +16,7 @@ func HasuraConnectionReader(hc *common.HasuraConnection, fromHasuraToBrowserChan
defer wg.Done()
defer hc.ContextCancelFunc()
defer log.Info("finished")
defer log.Debugf("finished")
for {
// Read a message from hasura
@ -50,7 +50,7 @@ func HasuraConnectionReader(hc *common.HasuraConnection, fromHasuraToBrowserChan
hc.Browserconn.ActiveSubscriptionsMutex.Lock()
delete(hc.Browserconn.ActiveSubscriptions, queryId)
hc.Browserconn.ActiveSubscriptionsMutex.Unlock()
log.Infof("Subscription with Id %s finished by Hasura.", queryId)
log.Debugf("Subscription with Id %s finished by Hasura.", queryId)
}
//Apply msg patch when it supports it

View File

@ -21,7 +21,7 @@ func HasuraConnectionWriter(hc *common.HasuraConnection, fromBrowserChannel chan
defer wg.Done()
defer hc.ContextCancelFunc()
defer log.Infof("finished")
defer log.Debugf("finished")
RangeLoop:
for {

View File

@ -47,7 +47,7 @@ func RemoveConnCacheDir(connectionId string) {
return
}
log.Infof("Directory of patch caches removed successfully for client %s.", connectionId)
log.Debugf("Directory of patch caches removed successfully for client %s.", connectionId)
}
func RemoveConnSubscriptionCacheFile(bConn *common.BrowserConnection, subscriptionId string) {
@ -61,7 +61,7 @@ func RemoveConnSubscriptionCacheFile(bConn *common.BrowserConnection, subscripti
return
}
log.Infof("Directory of patch caches removed successfully for client %s, subscription %s.", bConn.Id, subscriptionId)
log.Debugf("Directory of patch caches removed successfully for client %s, subscription %s.", bConn.Id, subscriptionId)
}
}

View File

@ -63,10 +63,12 @@ func ConnectionHandler(w http.ResponseWriter, r *http.Request) {
BrowserConnectionsMutex.Lock()
delete(BrowserConnections, browserConnectionId)
BrowserConnectionsMutex.Unlock()
log.Infof("connection removed")
}()
// Log it
log.Printf("connection accepted")
log.Infof("connection accepted")
// Create channels
fromBrowserChannel1 := make(chan interface{}, bufferSize)
@ -75,7 +77,7 @@ func ConnectionHandler(w http.ResponseWriter, r *http.Request) {
// Ensure a hasura client is running while the browser is connected
go func() {
log.Printf("starting hasura client")
log.Debugf("starting hasura client")
BrowserConnectedLoop:
for {
@ -84,7 +86,7 @@ func ConnectionHandler(w http.ResponseWriter, r *http.Request) {
break BrowserConnectedLoop
default:
{
log.Printf("creating hasura client")
log.Debugf("creating hasura client")
BrowserConnectionsMutex.RLock()
thisBrowserConnection := BrowserConnections[browserConnectionId]
BrowserConnectionsMutex.RUnlock()

View File

@ -48,15 +48,15 @@ func BrowserConnectionInvalidator() {
messageCoreAsMap := messageAsMap["core"].(map[string]interface{})
messageBodyAsMap := messageCoreAsMap["body"].(map[string]interface{})
sessionTokenToInvalidate := messageBodyAsMap["sessionToken"]
log.Infof("Received invalidate request for sessionToken %v", sessionTokenToInvalidate)
log.Debugf("Received invalidate request for sessionToken %v", sessionTokenToInvalidate)
websrv.BrowserConnectionsMutex.RLock()
for _, browserConnection := range websrv.BrowserConnections {
if browserConnection.SessionToken == sessionTokenToInvalidate {
if browserConnection.HasuraConnection != nil {
log.Infof("Processing invalidate request for sessionToken %v (hasura connection %v)", sessionTokenToInvalidate, browserConnection.HasuraConnection.Id)
log.Debugf("Processing invalidate request for sessionToken %v (hasura connection %v)", sessionTokenToInvalidate, browserConnection.HasuraConnection.Id)
browserConnection.HasuraConnection.ContextCancelFunc()
log.Infof("Processed invalidate request for sessionToken %v (hasura connection %v)", sessionTokenToInvalidate, browserConnection.HasuraConnection.Id)
log.Debugf("Processed invalidate request for sessionToken %v (hasura connection %v)", sessionTokenToInvalidate, browserConnection.HasuraConnection.Id)
}
}
}

View File

@ -26,7 +26,7 @@ func BrowserConnectionReader(browserConnectionId string, ctx context.Context, c
time.Sleep(100 * time.Millisecond)
}()
defer log.Infof("finished")
defer log.Debugf("finished")
for {
ctx, cancel := context.WithCancel(ctx)

View File

@ -10,7 +10,7 @@ func SessionTokenReader(connectionId string, browserConnectionContext context.Co
log := log.WithField("_routine", "SessionTokenReader")
defer wg.Done()
defer log.Info("finished")
defer log.Debugf("finished")
BrowserConnectionsMutex.RLock()
browserConnection := BrowserConnections[connectionId]

View File

@ -13,7 +13,7 @@ func BrowserConnectionWriter(browserConnectionId string, ctx context.Context, c
log := log.WithField("_routine", "websocketConnectionWriter").WithField("browserConnectionId", browserConnectionId)
defer wg.Done()
defer log.Printf("finished")
defer log.Debugf("finished")
RangeLoop:
for {

View File

@ -1,6 +1,7 @@
HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:bbb_graphql@localhost:5432/hasura_app
#HASURA_GRAPHQL_METADATA_DATABASE_URL=postgres://postgres:bbb_graphql@localhost:5432/hasura_app
#HASURA_GRAPHQL_NO_OF_RETRIES
HASURA_GRAPHQL_LOG_LEVEL=warn
HASURA_GRAPHQL_ENABLE_CONSOLE=false
HASURA_GRAPHQL_LIVE_QUERIES_MULTIPLEXED_REFETCH_INTERVAL=250
HASURA_GRAPHQL_STREAMING_QUERIES_MULTIPLEXED_REFETCH_INTERVAL=100