From c911fd77f11bacd522edfb386d03d549ee2ace2b Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 30 May 2024 13:33:49 +0200 Subject: [PATCH] improve: logging during startup sequence (#244) --- src/index.ts | 9 ++++++--- src/services/mongoService.ts | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 48e2de346..57381218d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,11 @@ +import { logger } from "./utils/logger"; + +logger.info("Starting up..."); + import http from "http"; import https from "https"; import fs from "node:fs"; import { app } from "./app"; -import { logger } from "./utils/logger"; import { config } from "./services/configService"; //const morgan = require("morgan"); //const bodyParser = require("body-parser"); @@ -17,10 +20,10 @@ const httpPort = config.httpPort || 80; const httpsPort = config.httpsPort || 443; // const server = http.createServer(app).listen(80); -http.createServer(app).listen(httpPort, () => logger.info("cache server started on port " + httpPort)); +http.createServer(app).listen(httpPort, () => logger.info("HTTP server started on port " + httpPort)); const server = https .createServer(options, app) - .listen(httpsPort, () => logger.info("game server started on port " + httpsPort)); + .listen(httpsPort, () => logger.info("HTTPS server started on port " + httpsPort)); // server.keepAliveTimeout = 60 * 1000 + 1000; // server.headersTimeout = 60 * 1000 + 2000; diff --git a/src/services/mongoService.ts b/src/services/mongoService.ts index 0c24c3ded..a90b6f8e4 100644 --- a/src/services/mongoService.ts +++ b/src/services/mongoService.ts @@ -11,10 +11,10 @@ if (url === undefined) { const connectDatabase = async () => { try { await mongoose.connect(`${url}`); - logger.info("connected to MongoDB"); + logger.info("Connected to MongoDB"); } catch (error: unknown) { if (error instanceof Error) { - logger.error(`error connecting to MongoDB ${error.message}`); + logger.error(`Error connecting to MongoDB ${error.message}`); } } };