mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
Add logger to main
+ Remove whitespace
This commit is contained in:
@@ -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
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user