Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
keefertaylor committed Nov 18, 2023
1 parent 18dd125 commit bbdef93
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# HealthChecks
<div align="center">
<p style="font-size:24px; font-weight: bold;">Pickaxe</p>
<p>
<img alt="Tessellated Logo" src="media/tessellated-logo.png" />
<small>Software by <a href="https://tessellated.io" target="_blank"> Tessellated // tessellated.io</a></small>
</p>
</div>

---

`healthchecks` is a light and convenient wrapper around the [healthchecks.io API](https://healthchecks.io) which monitors deadman's switches
within our infrastructure and services.
Expand Down
21 changes: 15 additions & 6 deletions health/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func NewHealthClient(logger *log.Logger, pingKey string, createNewChecks bool) H
// HealthCheck Interface

func (hc *healthClient) SendSuccess(slug string) error {
hc.logger.Info().Str("slug", slug).Msg("sending success")

shouldCreateNewChecks := hc.createNewChecksValue()
url := fmt.Sprintf("https://hc-ping.com/%s/%s?create=%d", hc.pingKey, slug, shouldCreateNewChecks)
fmt.Println("url")
fmt.Println(url)

resp, err := hc.client.Get(url)
if err != nil {
Expand All @@ -55,20 +55,29 @@ func (hc *healthClient) SendSuccess(slug string) error {
if err != nil {
return err
}
fmt.Println("got a response")
fmt.Println(string(body))
// hc.logger.Info().Str("ressponse", string(body))
hc.logger.Debug().Str("response", string(body)).Int("status", resp.StatusCode).Str("slug", slug).Msg("got response from success call")

return nil
}

func (hc *healthClient) SendFailure(slug string) error {
hc.logger.Info().Str("slug", slug).Msg("sending failure")

shouldCreateNewChecks := hc.createNewChecksValue()
url := fmt.Sprintf("https://hc-ping.com/%s/%s/fail?create=%d", hc.pingKey, slug, shouldCreateNewChecks)
_, err := hc.client.Get(url)

resp, err := hc.client.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
hc.logger.Debug().Str("response", string(body)).Int("status", resp.StatusCode).Str("slug", slug).Msg("got response from failure call")

return nil
}

Expand Down
Binary file added media/tessellated-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bbdef93

Please sign in to comment.