18 lines
518 B
TypeScript
18 lines
518 B
TypeScript
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()
|
|
]
|
|
}); |