Schmavery / facebook-chat-api

Unofficial Facebook Chat API for Nodejs
MIT License
1.93k stars 596 forks source link

cancel log event listen when logout acc facebook on console #723

Open vanhocpham opened 5 years ago

vanhocpham commented 5 years ago
ERR! listen  Error: parseAndCheckLogin got status code: 400. Bailing out of trying to parse response.
ERR! listen     at D:\Work\Main_Work\chatbee\server\node_modules\facebook-chat-api\utils.js:1042:15
ERR! listen     at tryCatcher (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\util.js:26:23)
ERR! listen     at Function.Promise.attempt.Promise.try (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\method.js:31:24)
ERR! listen     at D:\Work\Main_Work\chatbee\server\node_modules\facebook-chat-api\utils.js:989:24
ERR! listen     at tryCatcher (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\util.js:26:23)
ERR! listen     at Promise._settlePromiseFromHandler (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\promise.js:510:31)
ERR! listen     at Promise._settlePromiseAt (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\promise.js:584:18)
ERR! listen     at Promise._settlePromises (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\promise.js:700:14)
ERR! listen     at Async._drainQueue (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\async.js:123:16)
ERR! listen     at Async._drainQueues (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\async.js:133:10)
ERR! listen     at Immediate.Async.drainQueues [as _onImmediate] (D:\Work\Main_Work\chatbee\server\node_modules\bluebird\js\main\async.js:15:14)
ERR! listen     at runCallback (timers.js:705:18)
ERR! listen     at tryOnImmediate (timers.js:676:5)
ERR! listen     at processImmediate (timers.js:658:5)

I wanna check when logout account facebook but api log error again, how to cancel log event listen notification error on console?

Thanks so & hope help me!

BadAimWeeb commented 5 years ago

You can use this commands api.setOptions({ logLevel: "silent" }); before logout to disable all logs. But... well, you can't see logout successfully log.

vanhocpham commented 5 years ago

Thanks bro lequanglam Hongarc, I resolved use example code, it can check logout & also disable all logs

var stopListening = api.listen (async (err, event) => {
   if (err || err !== null) {
      console.error(err)
      return stopListening()
   }
} )