diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/index.rst | 1 | ||||
| -rw-r--r-- | docs/logging.rst | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/docs/index.rst b/docs/index.rst index 2e0d878d..7f3ab9d7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,6 +11,7 @@ Contents: .. toctree:: :maxdepth: 2 + logging api diff --git a/docs/logging.rst b/docs/logging.rst new file mode 100644 index 00000000..86a31ae7 --- /dev/null +++ b/docs/logging.rst @@ -0,0 +1,24 @@ +Setting Up Logging +=================== + +Newer version of *discord.py* have the capability of logging certain events via the `logging`_ python module. + +This is helpful if you want to see certain issues in *discord.py* or want to listen to events yourself. + +Setting up logging is fairly simple: :: + + import discord + import logging + + logger = logging.getLogger('discord') + logger.setLevel(logging.DEBUG) + handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w') + handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) + logger.addHandler(handler) + +This would create a logger that writes to a file called ``discord.log``. This is recommended as there are a lot of events +logged at a time and it would clog out the stdout of your program. + +For more information, check the documentation and tutorial of the `logging`_ module. + +.. _logging: https://docs.python.org/2/library/logging.html |