Skip to content

Commit

Permalink
Update logging level
Browse files Browse the repository at this point in the history
  • Loading branch information
zijinlibraze committed Mar 11, 2024
1 parent 16fe971 commit 167e30b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"crypto/tls"
"encoding/json"
"io"
"log"
"log/slog"
"net"
"net/http"
"strconv"
Expand Down Expand Up @@ -184,18 +184,20 @@ func (c *Client) PushWithContext(ctx Context, n *Notification) (*Response, error

setHeaders(request, n)

log.Println("Request url:")
log.Println(string(url))
if slog.Default().Enabled(context.Background(), slog.LevelDebug) {
slog.Debug("Request url:")
slog.Debug(string(url))

log.Println("Request payload:")
log.Println(string(payload))
slog.Debug("Request payload:")
slog.Debug(string(payload))

log.Println("Request headers:")
headerJson, err := json.Marshal(request.Header)
if err != nil {
log.Println("Error marshaling header:", err)
} else {
log.Println("Header:", string(headerJson))
slog.Debug("Request headers:")
headerJson, err := json.Marshal(request.Header)
if err != nil {
slog.Debug("Error marshaling header:", err)
} else {
slog.Debug("Header:", string(headerJson))
}
}

response, err := c.HTTPClient.Do(request)
Expand Down

0 comments on commit 167e30b

Please sign in to comment.