3232from telegram .ext import dispatcher , Dispatcher , JobQueue , UpdateQueue
3333from telegram .utils .webhookhandler import (WebhookServer , WebhookHandler )
3434
35- H = NullHandler ()
36- logging .getLogger (__name__ ).addHandler (H )
35+ logging .getLogger (__name__ ).addHandler (NullHandler ())
3736
3837
3938class Updater :
@@ -194,7 +193,7 @@ def _start_polling(self, poll_interval, timeout, network_delay):
194193 """
195194
196195 cur_interval = poll_interval
197- self .logger .info ('Updater thread started' )
196+ self .logger .debug ('Updater thread started' )
198197
199198 # Remove webhook
200199 self .bot .setWebhook (webhook_url = None )
@@ -216,8 +215,8 @@ def _start_polling(self, poll_interval, timeout, network_delay):
216215 else :
217216 if not self .running :
218217 if len (updates ) > 0 :
219- self .logger .info ('Updates ignored and will be pulled '
220- 'again on restart.' )
218+ self .logger .debug ('Updates ignored and will be pulled '
219+ 'again on restart.' )
221220 break
222221
223222 if updates :
@@ -241,7 +240,7 @@ def _increase_poll_interval(current_interval):
241240 return current_interval
242241
243242 def _start_webhook (self , listen , port , url_path , cert , key ):
244- self .logger .info ('Updater thread started' )
243+ self .logger .debug ('Updater thread started' )
245244 use_ssl = cert is not None and key is not None
246245 url_path = "/%s" % url_path
247246
@@ -274,7 +273,7 @@ def _start_webhook(self, listen, port, url_path, cert, key):
274273 self .httpd .serve_forever (poll_interval = 1 )
275274
276275 def _clean_updates (self ):
277- self .logger .info ('Cleaning updates from Telegram server' )
276+ self .logger .debug ('Cleaning updates from Telegram server' )
278277 updates = self .bot .getUpdates ()
279278 while updates :
280279 updates = self .bot .getUpdates (updates [- 1 ].update_id + 1 )
@@ -287,7 +286,7 @@ def stop(self):
287286 self .job_queue .stop ()
288287 with self .__lock :
289288 if self .running :
290- self .logger .info ('Stopping Updater and Dispatcher...' )
289+ self .logger .debug ('Stopping Updater and Dispatcher...' )
291290
292291 self .running = False
293292
@@ -301,31 +300,31 @@ def stop(self):
301300
302301 def _stop_httpd (self ):
303302 if self .httpd :
304- self .logger .info (
303+ self .logger .debug (
305304 'Waiting for current webhook connection to be '
306305 'closed... Send a Telegram message to the bot to exit '
307306 'immediately.' )
308307 self .httpd .shutdown ()
309308 self .httpd = None
310309
311310 def _stop_dispatcher (self ):
312- self .logger .debug (" Requesting Dispatcher to stop..." )
311+ self .logger .debug (' Requesting Dispatcher to stop...' )
313312 self .dispatcher .stop ()
314313
315314 def _join_async_threads (self ):
316315 with dispatcher .async_lock :
317316 threads = list (dispatcher .async_threads )
318317 total = len (threads )
319318 for i , thr in enumerate (threads ):
320- self .logger .info (
319+ self .logger .debug (
321320 'Waiting for async thread {0}/{1} to end' .format (i , total ))
322321 thr .join ()
323322 self .logger .debug (
324323 'async thread {0}/{1} has ended' .format (i , total ))
325324
326325 def _join_threads (self ):
327326 for thr in self .__threads :
328- self .logger .info (
327+ self .logger .debug (
329328 'Waiting for {0} thread to end' .format (thr .name ))
330329 thr .join ()
331330 self .logger .debug ('{0} thread has ended' .format (thr .name ))
0 commit comments