From 9444b01f36be397a0692094bf16313bfed79c2bd Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Wed, 23 Aug 2023 20:31:47 -0700 Subject: [PATCH] error logging --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d8d1c28..b363d5c 100644 --- a/main.go +++ b/main.go @@ -79,10 +79,13 @@ func (in *Instancer) registerEndpoints() { manifest, ok := in.config.Challenges[chalName] if !ok { + // todo: don't sprintf user controlled data + c.Logger().Infof("request rejected with invalid challenge %s", chalName) return c.JSON(http.StatusNotFound, "challenge not supported") } // todo: check an auth token or something if token == "" { + c.Logger().Info("request rejected with no token") return c.JSON(http.StatusForbidden, "team token not provided") } // todo: create challenge @@ -99,9 +102,10 @@ func (in *Instancer) registerEndpoints() { } if err != nil { // todo: handle errors/cleanup incomplete deploys? + c.Logger().Errorf("could create an object: %s", err.Error()) return c.JSON(http.StatusInternalServerError, "challenge deploy failed: contact admin") } - + c.Logger().Info("provisioned new instance") return c.JSON(http.StatusAccepted, "created") })