Skip to content

Commit

Permalink
Merge pull request #18 from topfreegames/chore/improve-logging
Browse files Browse the repository at this point in the history
Add log for 500 requests
  • Loading branch information
miguelreiswildlife committed Apr 24, 2024
2 parents 16506f9 + a4c264a commit cffb9ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
- name: Run tests
run: make test
- name: Install goveralls
env:
GO111MODULE: off
run: go get github.com/mattn/goveralls
run: go get github.com/mattn/goveralls@v0.0.7
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 8 additions & 0 deletions api/sendmqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ func SendMqttHandler(app *App) func(c echo.Context) error {
}
workingString := fmt.Sprintf(`{"topic": "%s", "retained": %t, "payload": %v}`, topic, retained, string(b))

lg = lg.WithFields(log.Fields{
"topic": topic,
"retained": retained,
"payload": string(b),
"source": source,
})

var mqttLatency time.Duration
var beforeMqttTime, afterMqttTime time.Time

Expand All @@ -77,6 +84,7 @@ func SendMqttHandler(app *App) func(c echo.Context) error {

status := 200
if err != nil {
lg.WithError(err).Error("failed to send mqtt message")
status = 500
if e, ok := err.(*httpclient.HTTPError); ok {
status = e.StatusCode
Expand Down

0 comments on commit cffb9ae

Please sign in to comment.