aboutsummaryrefslogtreecommitdiff
path: root/docs/logging.rst
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-09-16 17:27:20 -0400
committerRapptz <[email protected]>2015-09-16 17:27:52 -0400
commitbbf1c5418b41289c6b85d3db8d1ff4c3a69fafd3 (patch)
tree819403c253373d928abe4295c0f8cfd2ae2e7ed0 /docs/logging.rst
parentDocument discord.utils.find function (diff)
downloaddiscord.py-bbf1c5418b41289c6b85d3db8d1ff4c3a69fafd3.tar.xz
discord.py-bbf1c5418b41289c6b85d3db8d1ff4c3a69fafd3.zip
Add support for logging.
Diffstat (limited to 'docs/logging.rst')
-rw-r--r--docs/logging.rst24
1 files changed, 24 insertions, 0 deletions
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