Prechádzať zdrojové kódy

Error logging in search callers

Achilleas Koutsou 6 rokov pred
rodič
commit
b7ef5d5506
1 zmenil súbory, kde vykonal 9 pridanie a 0 odobranie
  1. 9 0
      routes/search.go

+ 9 - 0
routes/search.go

@@ -148,13 +148,17 @@ func ExploreData(c *context.Context) {
 	res := libgin.SearchResults{}
 	if keywords == "" {
 		// no keywords submitted: don't search
+		log.Trace("Loading empty data search page")
 		c.Data["Blobs"] = res.Blobs
 		c.HTML(200, EXPLORE_DATA)
 		return
 	}
+
+	log.Trace("Searching data/blobs")
 	data, err := search(c, keywords, sType)
 	if err != nil {
 		// c.Handle(http.StatusInternalServerError, "Could not query", err)
+		log.Error(2, "Query returned error: %v", err)
 		c.Data["Blobs"] = res.Blobs
 		c.HTML(200, EXPLORE_DATA)
 		return
@@ -163,6 +167,7 @@ func ExploreData(c *context.Context) {
 	err = json.Unmarshal(data, &res)
 	if err != nil {
 		// c.Handle(http.StatusInternalServerError, "Could not display result", err)
+		log.Error(2, "Failed to unmarshal response: %v", err)
 		c.Data["Blobs"] = res.Blobs
 		c.HTML(200, EXPLORE_DATA)
 		return
@@ -187,17 +192,20 @@ func ExploreCommits(c *context.Context) {
 
 	res := libgin.SearchResults{}
 	if keywords == "" {
+		log.Trace("Loading empty commit search page")
 		// no keywords submitted: don't search
 		c.Data["Commits"] = res.Commits
 		c.HTML(200, EXPLORE_COMMITS)
 		return
 	}
 
+	log.Trace("Searching commits")
 	data, err := search(c, keywords, sType)
 
 	if err != nil {
 		// c.Handle(http.StatusInternalServerError, "Could not query", err)
 		// return
+		log.Error(2, "Query returned error: %v", err)
 		c.Data["Commits"] = res.Commits
 		c.HTML(200, EXPLORE_COMMITS)
 	}
@@ -205,6 +213,7 @@ func ExploreCommits(c *context.Context) {
 	err = json.Unmarshal(data, &res)
 	if err != nil {
 		// c.Handle(http.StatusInternalServerError, "Could not display result", err)
+		log.Error(2, "Failed to unmarshal response: %v", err)
 		c.Data["Commits"] = res.Commits
 		c.HTML(200, EXPLORE_COMMITS)
 		return