2017-11-20 07:12:31 +03:00
|
|
|
================
|
2018-01-05 02:59:53 +03:00
|
|
|
Enabling Logging
|
2017-11-20 07:12:31 +03:00
|
|
|
================
|
|
|
|
|
|
|
|
Telethon makes use of the `logging`__ module, and you can enable it as follows:
|
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
.. code:: python
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
import logging
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
The library has the `NullHandler`__ added by default so that no log calls
|
|
|
|
will be printed unless you explicitly enable it.
|
|
|
|
|
|
|
|
You can also `use the module`__ on your own project very easily:
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: python
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
logger.debug('Debug messages')
|
|
|
|
logger.info('Useful information')
|
|
|
|
logger.warning('This is a warning!')
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
If you want to enable ``logging`` for your project *but* use a different
|
|
|
|
log level for the library:
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: python
|
2018-01-05 02:59:53 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
import logging
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
# For instance, show only warnings and above
|
|
|
|
logging.getLogger('telethon').setLevel(level=logging.WARNING)
|
2018-01-05 02:59:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
__ https://docs.python.org/3/library/logging.html
|
|
|
|
__ https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
|
|
|
|
__ https://docs.python.org/3/howto/logging.html
|