This commit is contained in:
parent
badd232d3d
commit
0dd928b8f4
@ -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
18
src/log.ts
Normal 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()
|
||||
]
|
||||
});
|
@ -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 }
|
Loading…
x
Reference in New Issue
Block a user