Skip to content

Commit 161d7b1

Browse files
committed
refactor: remove std/log
1 parent 49878af commit 161d7b1

File tree

4 files changed

+10
-54
lines changed

4 files changed

+10
-54
lines changed

deno.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"imports": {
1515
"@hono/hono": "jsr:@hono/hono@^4.6.13",
1616
"@lambdalisue/github-emoji": "jsr:@lambdalisue/github-emoji@^1.0.0",
17-
"@std/encoding": "jsr:@std/encoding@^1.0.5",
18-
"@std/log": "jsr:@std/log@^0.224.11"
17+
"@std/encoding": "jsr:@std/encoding@^1.0.5"
1918
},
2019
"unstable": [
2120
"kv"

deno.lock

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
import { Hono } from "@hono/hono";
22
import { HTTPException } from "@hono/hono/http-exception";
33
import { logger } from "@hono/hono/logger";
4-
import * as log from "@std/log";
54

65
import config from "./config.ts";
76
import { hasKey, verify } from "./crypto.ts";
87
import handler from "./handler.ts";
98

10-
function setupLogs() {
11-
log.setup({
12-
handlers: {
13-
console: new log.ConsoleHandler("DEBUG", {
14-
formatter: (rec) => `${rec.datetime.toISOString()} [${rec.levelName}] ${rec.msg}`,
15-
}),
16-
},
17-
loggers: {
18-
default: {
19-
level: config.debug ? "DEBUG" : "INFO",
20-
handlers: ["console"],
21-
},
22-
},
23-
});
24-
}
25-
269
const app = new Hono();
2710

2811
app.use(logger());
@@ -68,17 +51,15 @@ app.post("/:id/:token", async (c) => {
6851
});
6952

7053
if (import.meta.main) {
71-
setupLogs();
72-
7354
if (config.signKey) {
74-
log.info("url signing enabled");
55+
console.info("url signing enabled");
7556
}
7657

7758
Deno.serve(
7859
{
7960
hostname: config.hostname,
8061
port: config.port,
81-
onListen: () => log.info(`listening on ${config.hostname}:${config.port}`),
62+
onListen: () => console.info(`listening on ${config.hostname}:${config.port}`),
8263
},
8364
app.fetch,
8465
);

src/util.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as log from "@std/log";
2-
31
export function parseBool(s: string): boolean {
42
return ["1", "true", "on", "y", "yes"].includes(s.toLowerCase());
53
}
@@ -40,17 +38,17 @@ export function requestLog(headers: Record<string, string>) {
4038
// ugh
4139
// is there a better way to do this? certainly.
4240
// does this work? also yes.
43-
const proxyLog: (func: (s: any) => string) => (msg: any) => string = (func) => {
41+
const proxyLog: (func: (s: any) => void) => (msg: any) => void = (func) => {
4442
// FIXME: `String()` mangles objects
4543
return (msg) => func(prefix + String(msg));
4644
};
4745

4846
return {
49-
debug: proxyLog(log.debug),
50-
info: proxyLog(log.info),
51-
warn: proxyLog(log.warn),
52-
error: proxyLog(log.error),
53-
critical: proxyLog(log.critical),
47+
debug: proxyLog(console.debug),
48+
info: proxyLog(console.info),
49+
log: proxyLog(console.log),
50+
warn: proxyLog(console.warn),
51+
error: proxyLog(console.error),
5452
};
5553
}
5654

0 commit comments

Comments
 (0)