Backend/NodeJS
How to use Winston to log node application with telegram.
하우아유두잉
2019. 12. 19. 18:47
I use winston-telegram
How get telegram bot token & chatId : LINK
Example:
const wstlogger = require("winston");
const TelegramLogger = require("winston-telegram");
wstlogger.add(new TelegramLogger(
{
token: process.env.TELBOT_TOKEN,
chatId: process.env.TELBOT_CHATID,
level: "warn",
unique: true,
formatMessage: function (options: any) {
let message = options.message;
if (options.level === "warn") {
message = "[Warning] " + message;
}
return message;
}
}
));
wstlogger.warn("Some warning!!");
실행
$ yarn start