diff --git a/docs/features/logging.rst b/docs/features/logging.rst index b16c9bfd1..4b9f254a5 100644 --- a/docs/features/logging.rst +++ b/docs/features/logging.rst @@ -1,11 +1,35 @@ -|stub| Logging -============== +Logging +======= -|stub-desc| +Discord.Net will log all of its events/exceptions using a built-in LogManager. +This LogManager can be accessed through DiscordClient.Log + +Usage +----- + +To handle Log Messages through Discord.Net's Logger, you must hook into the Log.Message Event. + +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 +See the Example for a snippet of logging. + +Logging Your Own Data +--------------------- + +The LogManager included in Discord.Net can also be used to log your own messages. + +You can use DiscordClient.Log.Log(LogSeverity, Source, Message, Exception), or one of the shortcut helpers, to log data. + +Example: +.. code-block:: c# + + _client.MessageReceived += async (s, e) { + // Log a new Message with Severity Info, Sourced from 'MessageReceived', with the Message Contents. + _client.Log.Info("MessageReceived", e.Message.Text, null); + }; Example ------- .. literalinclude:: /samples/logging.cs - :language: csharp6 - :tab-width: 2 \ No newline at end of file + :language: c# + :tab-width: 2 diff --git a/docs/features/profile.rst b/docs/features/profile.rst deleted file mode 100644 index 4abb4e99b..000000000 --- a/docs/features/profile.rst +++ /dev/null @@ -1,4 +0,0 @@ -|stub| Profile -=================== - -|stub-desc| \ No newline at end of file diff --git a/docs/samples/logging.cs b/docs/samples/logging.cs index ae5f9f03b..c68b8aded 100644 --- a/docs/samples/logging.cs +++ b/docs/samples/logging.cs @@ -3,13 +3,14 @@ class Program private static DiscordBotClient _client; static void Main(string[] args) { - var client = new DiscordClient(new DiscordClientConfig { - //Warning: Debug mode should only be used for identifying problems. It _will_ slow your application down. - LogLevel = LogMessageSeverity.Debug - }); - client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}"); - - client.Run(async () => + var client = new DiscordClient(x => + { + LogLevel = LogSeverity.Info + }); + + _client.Log.Message += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}"); + + client.ExecuteAndWait(async () => { await client.Connect("discordtest@email.com", "Password123"); if (!client.Servers.Any())