tweak logging & add token deletion

This commit is contained in:
Enstrayed
2024-08-23 19:54:54 -07:00
parent f118e8a2bf
commit 2e527a8539
2 changed files with 44 additions and 1 deletions

View File

@@ -11,7 +11,16 @@ function logRequest(response,request,code,extra) {
} else {
actualExtra = ""
}
console.log(`${request.get("cf-connecting-ip") ?? request.ip} (${request.get("Authorization")}) ${request.method} ${request.path} returned ${code}${actualExtra}`)
if (request.get("Authorization")) {
actualAuth = `(${request.get("Authorization")})`
} else {
actualAuth = ""
}
// Client IP if connecting over Cloudflare, else IP as received by Express
// | / Token used (if provided)
// | / | Request Method Request Path Status code returned to client provided by function call
// V V V V V V Extra information if provided by function call
console.log(`${request.get("cf-connecting-ip") ?? request.ip}${actualAuth}${request.method} ${request.path} returned ${code}${actualExtra}`)
}
module.exports = { logRequest }