diff options
author | Alan Pearce | 2024-04-09 11:53:27 +0200 |
---|---|---|
committer | Alan Pearce | 2024-04-09 11:56:44 +0200 |
commit | d867b4d31be01f3114c3417c4114a3896cfe096c (patch) | |
tree | 044e714c36813733076171856af0a4cedb209bcd | |
parent | 2d40fe2ceb36391cd2049f2f8689a9123bf024be (diff) | |
download | website-d867b4d31be01f3114c3417c4114a3896cfe096c.tar.lz website-d867b4d31be01f3114c3417c4114a3896cfe096c.tar.zst website-d867b4d31be01f3114c3417c4114a3896cfe096c.zip |
Use log methods instead of console
-rw-r--r-- | src/app.ts | 6 | ||||
-rw-r--r-- | src/index.ts | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/app.ts b/src/app.ts index 317b9c0..6cc6520 100644 --- a/src/app.ts +++ b/src/app.ts @@ -65,7 +65,7 @@ function registerFile( pathname = "/" + (pathname === "." || pathname === "./" ? "" : pathname); if (files.get(pathname) !== undefined) { - console.warn("File already registered:", pathname); + log.warn("File already registered:", pathname); } const handle = Bun.file(filename); files.set(pathname, { @@ -280,13 +280,13 @@ export const server = { content_encoding: "identity", }); Sentry.captureException(error); - console.error("Error", error); + log.error("Error", error); return new Response("Something went wrong", { status: status }); } finally { const seconds = endTimer(); metrics.requestDuration.observe(seconds); transaction.finish(); - console.info( + log.info( request.method, status, hostname, diff --git a/src/index.ts b/src/index.ts index 17eacd8..0591e6d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,10 +5,10 @@ import { server, metricsServer } from "./app"; log.setLevel((import.meta.env["LOG_LEVEL"] || "info") as log.LogLevelDesc); const metricsServed = Bun.serve(metricsServer); -console.info(`Metrics server started on port ${metricsServed.port}`); +log.info(`Metrics server started on port ${metricsServed.port}`); const served = Bun.serve(server); -console.info(`Serving website on ${served.url}`); +log.info(`Serving website on ${served.url}`); process.on("SIGTERM", function () { log.info("SIGTERM received, shutting down..."); |