cleanup
This commit is contained in:
31
src/utils/logger.ts
Normal file
31
src/utils/logger.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import Winston, { format } from "winston";
|
||||
const { colorize, timestamp, printf } = format;
|
||||
|
||||
interface LogInfo {
|
||||
level: string;
|
||||
message: string;
|
||||
label?: string;
|
||||
timestamp?: string;
|
||||
}
|
||||
|
||||
const customFormat = format.combine(
|
||||
timestamp({ format: "YY-MM-DD HH:MM:SS" }),
|
||||
printf((info: LogInfo) => {
|
||||
return `[${info.timestamp}] ${info.level}: ${info.message}`;
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* The global logger instance.
|
||||
*/
|
||||
export const logger = Winston.createLogger({
|
||||
transports: [
|
||||
new Winston.transports.Console({
|
||||
format: Winston.format.combine(colorize(), customFormat),
|
||||
}),
|
||||
new Winston.transports.File({
|
||||
filename: `data/logs/${new Date().toISOString().slice(0, 10)}.log`,
|
||||
format: Winston.format.combine(customFormat),
|
||||
}),
|
||||
],
|
||||
});
|
8
src/utils/timeUtils.ts
Normal file
8
src/utils/timeUtils.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Gets the current date as YYYY-MM-DD.
|
||||
*
|
||||
* @returns the date
|
||||
*/
|
||||
export function getFormattedDate() {
|
||||
return new Date().toISOString().slice(0, 10);
|
||||
}
|
Reference in New Issue
Block a user