Skip to content

Commit 5e0af9f

Browse files
committed
feat: add User-Agent field to access log
1 parent c4a0f83 commit 5e0af9f

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/services/log.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,26 @@ export const sendAccessLog = async (c: Context, others: boolean) => {
3030
second: "numeric",
3131
});
3232

33-
await sendDiscordWebhook(
34-
webhookURL,
35-
{
36-
content: c.req.path,
37-
embeds: [
38-
{
39-
description: `[${c.req.method}] ${c.req.url} - ${c.res.status}`,
40-
color: others ? 0xffff00 : 0x008000,
41-
footer: {
42-
text: `${time} - ${info.remote.address}`,
33+
const ua = c.req.header("user-agent") || "Unknown";
34+
35+
await sendDiscordWebhook(webhookURL, {
36+
content: c.req.path,
37+
embeds: [
38+
{
39+
description: `[${c.req.method}] ${c.req.url} - ${c.res.status}`,
40+
color: others ? 0xffff00 : 0x008000,
41+
fields: [
42+
{
43+
name: "User-Agent",
44+
value: ua,
4345
},
46+
],
47+
footer: {
48+
text: `${time} - ${info.remote.address}`,
4449
},
45-
],
46-
},
47-
);
50+
},
51+
],
52+
});
4853
};
4954

5055
export const sendAPIAccessLog = async (

0 commit comments

Comments
 (0)