Skip to content
Snippets Groups Projects
Commit 2fc38f41 authored by Flnal's avatar Flnal
Browse files

changed logs

parent 8891beca
No related branches found
No related tags found
1 merge request!3Master
......@@ -18,7 +18,7 @@ func CreateCampaign(w http.ResponseWriter, r *http.Request) {
return
}
if err := service.CreateCampaign(campaign); err != nil {
log.Printf("Error calling service CreateCampaign: %v", err)
log.Errorf("Error calling service CreateCampaign: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
......@@ -28,7 +28,7 @@ func CreateCampaign(w http.ResponseWriter, r *http.Request) {
func GetCampaigns(w http.ResponseWriter, _ *http.Request) {
campaigns, err := service.GetCampaigns()
if err != nil {
log.Printf("Error calling service GetCampaigns: %v", err)
log.Errorf("Error calling service GetCampaigns: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
......
......@@ -3,9 +3,14 @@ package handler
import (
"io"
"net/http"
log "github.com/sirupsen/logrus"
)
func Health(w http.ResponseWriter, r *http.Request) {
log.Infof(`{"alive": true}`)
//kann das gelöscht werden?
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, `{"alive": true}`)
}
package service
import (
"log"
log "github.com/sirupsen/logrus"
"gitlab.reutlingen-university.de/albrecht/myaktion-go/src/myaktion/model"
)
......@@ -19,8 +19,8 @@ func CreateCampaign(campaign *model.Campaign) error {
campaign.ID = actCampaignId
campaignStore[actCampaignId] = campaign
actCampaignId += 1
log.Printf("Successfully stored new campaign with ID %v in database.", campaign.ID)
log.Printf("Stored: %v", campaign)
log.Infof("Successfully stored new campaign with ID %v in database.", campaign.ID)
log.Tracef("Stored: %v", campaign)
return nil
}
......@@ -29,6 +29,6 @@ func GetCampaigns() ([]model.Campaign, error) {
for _, campaign := range campaignStore {
campaigns = append(campaigns, *campaign)
}
log.Printf("Retrieved: %v", campaigns)
log.Tracef("Retrieved: %v", campaigns)
return campaigns, nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment