Browse Source

fix: Various log noise

jamesread 8 months ago
parent
commit
39664a734d

+ 8 - 1
service/internal/acl/acl.go

@@ -208,12 +208,19 @@ func UserFromContext[T any](ctx context.Context, req *connect.Request[T], cfg *c
 	} else {
 		buildUserAcls(cfg, &user)
 	}
+
+	path := ""
+	if req != nil {
+		path = req.Spec().Procedure
+	}
+
 	log.WithFields(log.Fields{
 		"username":      user.Username,
 		"usergroupLine": user.UsergroupLine,
 		"provider":      user.Provider,
 		"acls":          user.Acls,
-	}).Debugf("UserFromContext")
+		"path":          path,
+	}).Debugf("Authenticated API request")
 	return &user
 }
 

+ 4 - 2
service/internal/api/api.go

@@ -662,7 +662,9 @@ func (api *oliveTinAPI) EventStream(ctx ctx.Context, req *connect.Request[apiv1.
 		AuthenticatedUser: user,
 	}
 
-	log.Infof("EventStream: client connected: %v", client.AuthenticatedUser.Username)
+	log.WithFields(log.Fields{
+		"authenticatedUser": user.Username,
+	}).Debugf("EventStream: client connected")
 
 	api.streamingClientsMutex.Lock()
 	api.streamingClients[client] = struct{}{}
@@ -814,7 +816,7 @@ func (api *oliveTinAPI) buildRootDashboards(user *acl.AuthenticatedUser, dashboa
 func (api *oliveTinAPI) addDefaultDashboardIfNeeded(rootDashboards *[]string, rr *DashboardRenderRequest) {
 	defaultDashboard := buildDefaultDashboard(rr)
 	if defaultDashboard != nil && len(defaultDashboard.Contents) > 0 {
-		log.Infof("defaultDashboard: %+v", defaultDashboard.Contents)
+		log.Tracef("defaultDashboard: %+v", defaultDashboard.Contents)
 		*rootDashboards = append(*rootDashboards, "Actions")
 	}
 }

+ 3 - 1
service/internal/executor/executor_actions.go

@@ -53,7 +53,9 @@ func (e *Executor) RebuildActionMap() {
 
 	findDashboardActionTitles(req)
 
-	log.Infof("dashboardActionTitles: %v", req.DashboardActionTitles)
+	log.WithFields(log.Fields{
+		"titles": req.DashboardActionTitles,
+	}).Trace("dashboardActionTitles")
 
 	for configOrder, action := range e.Cfg.Actions {
 		if action.Entity != "" {

+ 5 - 1
service/internal/httpservers/singleFrontend.go

@@ -53,7 +53,11 @@ func StartSingleHTTPFrontend(cfg *config.Config, ex *executor.Executor) {
 
 		r.URL.Path = apiPath + fn
 
-		log.Debugf("SingleFrontend HTTP API Req URL after rewrite: %v", r.URL.Path)
+		log.WithFields(log.Fields{
+			"path": r.URL.Path,
+		}).Tracef("SingleFrontend HTTP API Req URL after rewrite")
+
+		logDebugRequest(cfg, "api", r)
 
 		apiHandler.ServeHTTP(w, r)
 	}))

+ 1 - 1
service/internal/httpservers/webuiServer.go

@@ -45,7 +45,7 @@ func (s *webUIServer) handleWebui(w http.ResponseWriter, r *http.Request) {
 
 		http.ServeFile(w, r, path.Join(s.webuiDir, "index.html"))
 	} else {
-		log.Infof("Serving webui from %s for %s", s.webuiDir, r.URL.Path)
+		log.Tracef("Serving webui from %s for %s", s.webuiDir, r.URL.Path)
 		http.ServeFile(w, r, path.Join(s.webuiDir, r.URL.Path))
 		//		http.StripPrefix(dirName, http.FileServer(http.Dir(s.webuiDir))).ServeHTTP(w, r)
 	}

+ 10 - 3
service/main.go

@@ -151,10 +151,17 @@ func initConfig(configDir string) {
 	for _, directory := range directories {
 		configPath := getConfigPath(directory)
 
-		log.Debugf("Checking config path: %s", configPath)
-
+		found := true
 		if _, err := os.Stat(configPath); err != nil {
-			log.Debugf("Config file not found at %s: %v", configPath, err)
+			found = false
+		}
+
+		log.WithFields(log.Fields{
+			"configPath": configPath,
+			"found":      found,
+		}).Debug("Checking config path")
+
+		if !found {
 			continue
 		}