Skip to content

Commit

Permalink
docs(readme) : update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Oct 25, 2023
1 parent bb910ee commit 1879918
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 1879918

Please sign in to comment.