Skip to content

Instantly share code, notes, and snippets.

@erayakartuna
Created January 2, 2022 20:10
Show Gist options
  • Save erayakartuna/ce17f5493cb1482b53c677836c467c58 to your computer and use it in GitHub Desktop.
Save erayakartuna/ce17f5493cb1482b53c677836c467c58 to your computer and use it in GitHub Desktop.
Logv1.go
type requestLogs struct {
logs []string
sync.Mutex
}
var reqLogs requestLogs
func LogRequest(url string, reqBody string, respStatus int, resp string) {
l := fmt.Sprintf(
`{"url": "%s", "reqBody": "%s", "respStatus": "%d", "resp": "%s"\n\r`,
jsonEscape(url),
jsonEscape(reqBody),
respStatus,
jsonEscape(resp),
)
reqLogs.Lock()
reqLogs.logs = append(reqLogs.logs, l)
reqLogs.Unlock()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment