Skip to content

Instantly share code, notes, and snippets.

View Aboubakary833's full-sized avatar
⚒️
Crafting

Aboubakary Cissé Aboubakary833

⚒️
Crafting
View GitHub Profile
@Aboubakary833
Aboubakary833 / logger.ts
Last active October 17, 2025 17:51
Solution for winstonjs logging to multiple transport files simultaneously instead of one. Issue link: https://github.com/winstonjs/winston/issues/614. Inspired solution proposal link: https://github.com/winstonjs/winston/issues/614#issuecomment-405015322
import { createLogger, format, transports } from "winston";
const { combine, json, prettyPrint, timestamp } = format;
const formatCombination = [json(), timestamp(), prettyPrint()];
const levels = ["info", "warn", "error", "fatal"] as const;
function getFilter(level: (typeof levels)[number]) {
return format((log, _) => (log.level === level ? log : false));
}