From 1879918458a034441911eaf7fe983756b92c83dd Mon Sep 17 00:00:00 2001 From: seipan Date: Thu, 26 Oct 2023 02:51:34 +0900 Subject: [PATCH] docs(readme) : update readme --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index ea87103..3c787e6 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,18 @@ func main() { If you do not want to be notified of a particular log level, you can set ```go +package discord + +import "github.com/seipan/loghook" + +var ( + // DiscordWebhookURL is a webhook url for discord. + DiscordWebhookURL = "https://discord.com/api/webhooks/xxxxxxxx/xxxxxxxx" +) + func main(){ + logger := loghook.NewLogger("", "test", "discord", DiscordWebhookURL) + logger.NoSendDebug() logger.Debug("test") logger.NoSendInfo() @@ -56,11 +67,39 @@ func main(){ ``` You can also change the webhook to be notified for each log level ```go +package discord + +import "github.com/seipan/loghook" + +var ( + // DiscordWebhookURL is a webhook url for discord. + DiscordWebhookURL = "https://discord.com/api/webhooks/xxxxxxxx/xxxxxxxx" +) + func main(){ + logger := loghook.NewLogger("", "test", "discord", DiscordWebhookURL) + logger.SetErrorWebhook(DiscordErrorWebhookURL) logger.Error("test") } ``` +There is also a method that takes 'context' as an argument +```go +package discord + +import "github.com/seipan/loghook" + +var ( + // DiscordWebhookURL is a webhook url for discord. + DiscordWebhookURL = "https://discord.com/api/webhooks/xxxxxxxx/xxxxxxxx" +) + +func main(){ + logger := loghook.NewLogger("", "test", "discord", DiscordWebhookURL) + + logger.ErrorContext("test") +} +``` If you want a more detailed example, please see the [examples](https://github.com/seipan/loghook/blob/main/example). ## License Code licensed under