working on logger
Some checks failed
Build / build (push) Failing after 54s

This commit is contained in:
Corban-Lee Jones 2025-05-05 23:39:22 +01:00
parent badd232d3d
commit 0dd928b8f4
3 changed files with 22 additions and 1 deletions

View File

@ -66,7 +66,8 @@
"preline": "^3.0.1",
"sqlite3": "^5.1.7",
"tsconfig-paths": "^4.2.0",
"vanilla-calendar-pro": "^3.0.4"
"vanilla-calendar-pro": "^3.0.4",
"winston": "^3.17.0"
},
"prisma": {
"seed": "ts-node prisma/seed.ts"

18
src/log.ts Normal file
View File

@ -0,0 +1,18 @@
import winston from "winston";
const { combine, timestamp, json, printf } = winston.format;
const timestampFormat = "YYYY-MM-DD HH:mm:ss";
export const logger = winston.createLogger({
format: combine(
timestamp({ format: timestampFormat }),
json(),
printf(({ timestamp, level, message, ...data }) => {
const response = { level, message, data };
return JSON.stringify(response);
})
),
transports: [
new winston.transports.Console()
]
});

View File

@ -1,7 +1,9 @@
import { Request, Response } from "express";
import { logger } from "src/log";
const get = async (_request: Request, response: Response) => {
response.render("home", { title: "home page" });
logger.info("Success");
};
export default { get }