Skip to content

Commit

Permalink
fix: better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Torwent committed Jun 27, 2024
1 parent 7417575 commit 6aa7604
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@ app.onResponse((response) => {
const userAgent = request.headers.get("user-agent")
const timestamp = new Date().toISOString().replace("T", " ").replace("Z", "")

let icon = "💯"
if (status) {
const n = status as number
if (n > 200 && n < 300) icon = "✅"
else if (n >= 300 && n < 400) icon = "💨"
else if (n >= 400 && n < 500) icon = "⚠️"
else if (n >= 500) icon = "❌"
}

console.log(
`[${timestamp}]: [${status === 200 ? "💯" : "✅"} ${status}] ${userAgent} ${ip + " " ?? ""}- ${request.method} ${path}`
`[${timestamp}]: [${icon} ${status}] ${userAgent} ${ip + " " ?? ""}- ${request.method} ${path}`
)
})

Expand Down

0 comments on commit 6aa7604

Please sign in to comment.