1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Updated Logging section in README

This commit is contained in:
pieter 2015-09-08 19:56:05 +02:00
parent 710fc273d6
commit 88bd6dcbb0
2 changed files with 7 additions and 9 deletions

View File

@ -353,15 +353,13 @@ If you prefer using web hooks to the getUpdates method, you can use the `process
### Logging ### Logging
You can use the Telebot module logger to log debug info about Telebot. Use `telebot.logger` to get the logger of the TeleBot module. You can use the Telebot module logger to log debug info about Telebot. Use `telebot.logger` to get the logger of the TeleBot module.
It is possible to add custom logging Handlers to the logger. Refer to the [Python logging module page](https://docs.python.org/2/library/logging.html) for more info.
```python ```python
import logging
logger = telebot.logger logger = telebot.logger
formatter = logging.Formatter('[%(asctime)s] %(thread)d {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', telebot.logger.setLevel(logging.DEBUG) # Outputs debug messages to console.
'%m-%d %H:%M:%S')
ch = logging.StreamHandler(sys.stdout)
logger.addHandler(ch)
logger.setLevel(logging.DEBUG) # or use logging.INFO
ch.setFormatter(formatter)
``` ```
## F.A.Q. ## F.A.Q.

View File

@ -10,9 +10,9 @@ import logging
logger = logging.getLogger('TeleBot') logger = logging.getLogger('TeleBot')
formatter = logging.Formatter('%(asctime)s (%(filename)s:%(lineno)d) %(levelname)s - %(name)s: "%(message)s"') formatter = logging.Formatter('%(asctime)s (%(filename)s:%(lineno)d) %(levelname)s - %(name)s: "%(message)s"')
ch = logging.StreamHandler(sys.stderr) console_output_handler = logging.StreamHandler(sys.stderr)
ch.setFormatter(formatter) console_output_handler.setFormatter(formatter)
logger.addHandler(ch) logger.addHandler(console_output_handler)
logger.setLevel(logging.ERROR) logger.setLevel(logging.ERROR)