Created
January 2, 2022 20:10
-
-
Save erayakartuna/ce17f5493cb1482b53c677836c467c58 to your computer and use it in GitHub Desktop.
Logv1.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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