Add logger to main

+ Remove whitespace
This commit is contained in:
Stephan
2022-04-28 14:39:16 +02:00
parent 9516b60d93
commit 9ac4fb8efd
2 changed files with 7 additions and 2 deletions
+3 -1
View File
@@ -7,7 +7,9 @@ const {
const defaultJsonFormat = combine(errors({ stack: true }), timestamp(), json({ space: 2 })); const defaultJsonFormat = combine(errors({ stack: true }), timestamp(), json({ space: 2 }));
const customCLIFormat = printf(({ level, message, label, timestamp, stack }) => { const customCLIFormat = printf(({ level, message, label, timestamp, stack }) => {
let output = `${level}${stack ? `(1/2:message)` : ""} at ${timestamp}${label ? ` (#${label})` : ""}: ${message}\n`; let output = `${level}${stack ? `(1/2:message)` : ""} at ${timestamp}${label ? ` (#${label})` : ""}: ${message}${
stack ? "\n" : ""
}`;
if (stack) { if (stack) {
output += `\n${level}(2/2:stack)${label ? ` (#${label})` : ""}: ${stack}\n\n`; output += `\n${level}(2/2:stack)${label ? ` (#${label})` : ""}: ${stack}\n\n`;
+4 -1
View File
@@ -7,6 +7,7 @@ import adminRouter from "./Routes/admin.routes";
import organisationRouter from "./Routes/organisation.routes"; import organisationRouter from "./Routes/organisation.routes";
import groupRouter from "./Routes/group.routes"; import groupRouter from "./Routes/group.routes";
import defaultErrorHandler from "./Middleware/error/handler"; import defaultErrorHandler from "./Middleware/error/handler";
import logger from "./Middleware/error/logger";
// Set up async error handling // Set up async error handling
require("express-async-errors"); require("express-async-errors");
@@ -60,8 +61,10 @@ async function main() {
app.use(defaultErrorHandler); app.use(defaultErrorHandler);
app.listen(process.env.PORT, () => { app.listen(process.env.PORT, () => {
console.log(`Listening on Port: ${process.env.PORT}`); logger.info(`Listening on port ${process.env.PORT}`);
}); });
logger.info("Server started");
} }
main() main()