Skip to content

Commit

Permalink
add slog error
Browse files Browse the repository at this point in the history
Co-authored-by: halprin <[email protected]>
  • Loading branch information
pluckyswan and halprin committed Oct 24, 2024
1 parent c81701b commit 2a3ed4d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ func setupLogging() {
func setupHealthCheck() {
slog.Info("Bootstrapping health check")

http.HandleFunc("/error", func(response http.ResponseWriter, request *http.Request) {
slog.Error("We hit an error!")

_, err := io.WriteString(response, "Generated an error log")
if err != nil {
slog.Error("Failed to respond to health check", slog.Any(utils.ErrorKey, err))
}
})

http.HandleFunc("/", func(response http.ResponseWriter, request *http.Request) {
slog.Info("Health check ping", slog.String("method", request.Method), slog.String("path", request.URL.String()))

Expand Down

0 comments on commit 2a3ed4d

Please sign in to comment.