You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

logging.rst 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435
  1. Logging
  2. =======
  3. Discord.Net will log all of its events/exceptions using a built-in LogManager.
  4. This LogManager can be accessed through DiscordClient.Log
  5. Usage
  6. -----
  7. To handle Log Messages through Discord.Net's Logger, you must hook into the Log.Message<LogMessageEventArgs> Event.
  8. The LogManager does not provide a string-based result for the message, you must put your own message format together using the data provided through LogMessageEventArgs
  9. See the Example for a snippet of logging.
  10. Logging Your Own Data
  11. ---------------------
  12. The LogManager included in Discord.Net can also be used to log your own messages.
  13. You can use DiscordClient.Log.Log(LogSeverity, Source, Message, Exception), or one of the shortcut helpers, to log data.
  14. Example:
  15. .. code-block:: c#
  16. _client.MessageReceived += async (s, e) {
  17. // Log a new Message with Severity Info, Sourced from 'MessageReceived', with the Message Contents.
  18. _client.Log.Info("MessageReceived", e.Message.Text, null);
  19. };
  20. Example
  21. -------
  22. .. literalinclude:: /samples/logging.cs
  23. :language: c#
  24. :tab-width: 2