-
How to use Winston to log node application with telegram.Backend/NodeJS 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
'Backend > NodeJS' 카테고리의 다른 글
[winston] How to log as daily rotate file (0) 2019.12.20 [winston] How to customize timestamp format. (to local timezone) 날짜 시간 포맷을 로컬 타임존으로 변경하기 (0) 2019.12.20 [node] express compression 메모리 최적화 (memory optimization) (0) 2019.12.18 ReferenceError: regeneratorRuntime is not defined (0) 2019.12.09 [node] How to send remind-push to customers (0) 2019.11.27