telebot icon indicating copy to clipboard operation
telebot copied to clipboard

What's the best way to implement Winston logger as a Telebot's middleware ?

Open ponsfrilus opened this issue 4 years ago • 1 comments

I was wondering if someone has already used Winston as a Telebot's logger middleware, because I'm not sure of the best way to do it: as a plugin, modifier, or just listen to every bot's events.

Any comments, opinions and remark on this matter would be much appreciated, thanks !

ponsfrilus avatar Sep 17 '20 17:09 ponsfrilus

You may listen the bot event, then write it on your logger.

// for any command
bot.on('/*', msg => {
  // run logger here
})

// for any incoming text
bot.on('text', msg => {
  // run logger here
})

PS: i'm not using logger for my own project, better to forward the log into my own telegram account for quick action and response :yum: IMHO

cikaldev avatar Mar 07 '21 17:03 cikaldev