Skip to content

Commit

Permalink
fix : remove discord slack
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Dec 30, 2023
1 parent 29337da commit 5d5da2c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 295 deletions.
94 changes: 3 additions & 91 deletions discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,94 +22,6 @@

package loghook

// This structure Discord holds the webhook url for logging to discord.
type Discord struct {
// This is the webhook url of the channel for which you want to send notifications to the discord.
webhook string

// This is the webhook url for debug level log
debugWebhook string

// This is the webhook url for info level log
infoWebhook string

// This is the webhook url for warn level log
warnWebhook string

// This is the webhook url for error level log
errorWebhook string

// This is the webhook url for panic level log
panicWebhook string

// This is the webhook url for fatal level log
fatalWebhook string
}

func NewDiscord(webhook string) *Discord {
return &Discord{webhook: webhook}
}

func (d *Discord) Webhook() string {
return d.webhook
}

func (d *Discord) DebugWebhook() string {
return d.debugWebhook
}

func (d *Discord) InfoWebhook() string {
return d.infoWebhook
}

func (d *Discord) WarnWebhook() string {
return d.warnWebhook
}

func (d *Discord) ErrorWebhook() string {
return d.errorWebhook
}

func (d *Discord) PanicWebhook() string {
return d.panicWebhook
}

func (d *Discord) FatalWebhook() string {
return d.fatalWebhook
}

// Sets the webhook url.
// This url will be used if the webhook url for any level is not set
func (d *Discord) SetWebhook(webhook string) {
d.webhook = webhook
}

// Set the webhookurl for the Debug level.
func (d *Discord) SetDebugWebhook(webhook string) {
d.debugWebhook = webhook
}

// Set the webhookurl for the Info level.
func (d *Discord) SetInfoWebhook(webhook string) {
d.infoWebhook = webhook
}

// Set the webhookurl for the Warn level.
func (d *Discord) SetWarnWebhook(webhook string) {
d.warnWebhook = webhook
}

// Set the webhookurl for the Error level.
func (d *Discord) SetErrorWebhook(webhook string) {
d.errorWebhook = webhook
}

// Set the webhookurl for the Panic level.
func (d *Discord) SetPanicWebhook(webhook string) {
d.panicWebhook = webhook
}

// Set the webhookurl for the Fatal level.
func (d *Discord) SetFatalWebhook(webhook string) {
d.fatalWebhook = webhook
}
const (
exampleDiscordInfoWebhook = "https://discord.com/api/webhooks/000000000000000000/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Check failure on line 26 in discord.go

View workflow job for this annotation

GitHub Actions / build (1.18)

const `exampleDiscordInfoWebhook` is unused (unused)

Check failure on line 26 in discord.go

View workflow job for this annotation

GitHub Actions / build (1.19)

const `exampleDiscordInfoWebhook` is unused (unused)

Check failure on line 26 in discord.go

View workflow job for this annotation

GitHub Actions / build (1.20)

const `exampleDiscordInfoWebhook` is unused (unused)

Check failure on line 26 in discord.go

View workflow job for this annotation

GitHub Actions / build (1.21)

const `exampleDiscordInfoWebhook` is unused (unused)

Check failure on line 26 in discord.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] discord.go#L26

const `exampleDiscordInfoWebhook` is unused (unused)
Raw output
discord.go:26:2: const `exampleDiscordInfoWebhook` is unused (unused)
	exampleDiscordInfoWebhook = "https://discord.com/api/webhooks/000000000000000000/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
	^
)
51 changes: 0 additions & 51 deletions discord_test.go

This file was deleted.

14 changes: 4 additions & 10 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ type Logger struct {

Types Option

Slack *Slack

Discord *Discord

SendLevel Level

// This is the url of the icon image of the bot that sends notifications to the discord
Expand All @@ -58,12 +54,10 @@ type Logger struct {

func NewLogger(img string, name string, types string, webhook string) *Logger {
return &Logger{
level: InfoLevel,
Img: img,
Name: name,
Types: *NewOption(types, ""),
Slack: NewSlack(webhook),
Discord: NewDiscord(webhook),
level: InfoLevel,
Img: img,
Name: name,
Types: *NewOption(types, ""),
}
}

Expand Down
95 changes: 3 additions & 92 deletions slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,95 +22,6 @@

package loghook

// This structure slack holds the webhook url for logging to slack.
// This webhook assumes that the Incoming Webhook is used.
type Slack struct {
// This is the webhook url of the channel for which you want to send notifications to the slack.
webhook string

// This is the webhook url for debug level log
debugWebhook string

// This is the webhook url for info level log
infoWebhook string

// This is the webhook url for warn level log
warnWebhook string

// This is the webhook url for error level log
errorWebhook string

// This is the webhook url for panic level log
panicWebhook string

// This is the webhook url for fatal level log
fatalWebhook string
}

func NewSlack(webhook string) *Slack {
return &Slack{webhook: webhook}
}

func (s *Slack) Webhook() string {
return s.webhook
}

func (s *Slack) DebugWebhook() string {
return s.debugWebhook
}

func (s *Slack) InfoWebhook() string {
return s.infoWebhook
}

func (s *Slack) WarnWebhook() string {
return s.warnWebhook
}

func (s *Slack) ErrorWebhook() string {
return s.errorWebhook
}

func (s *Slack) PanicWebhook() string {
return s.panicWebhook
}

func (s *Slack) FatalWebhook() string {
return s.fatalWebhook
}

// Sets the webhook url.
// This url will be used if the webhook url for any level is not set
func (s *Slack) SetWebhook(webhook string) {
s.webhook = webhook
}

// Set the webhookurl for the Debug level.
func (s *Slack) SetDebugWebhook(webhook string) {
s.debugWebhook = webhook
}

// Set the webhookurl for the Info level.
func (s *Slack) SetInfoWebhook(webhook string) {
s.infoWebhook = webhook
}

// Set the webhookurl for the Warn level.
func (s *Slack) SetWarnWebhook(webhook string) {
s.warnWebhook = webhook
}

// Set the webhookurl for the Error level.
func (s *Slack) SetErrorWebhook(webhook string) {
s.errorWebhook = webhook
}

// Set the webhookurl for the Panic level.
func (s *Slack) SetPanicWebhook(webhook string) {
s.panicWebhook = webhook
}

// Set the webhookurl for the Fatal level.
func (s *Slack) SetFatalWebhook(webhook string) {
s.fatalWebhook = webhook
}
const (
exampleSlackInfoWebhook = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"

Check failure on line 26 in slack.go

View workflow job for this annotation

GitHub Actions / build (1.18)

const `exampleSlackInfoWebhook` is unused (unused)

Check failure on line 26 in slack.go

View workflow job for this annotation

GitHub Actions / build (1.19)

const `exampleSlackInfoWebhook` is unused (unused)

Check failure on line 26 in slack.go

View workflow job for this annotation

GitHub Actions / build (1.20)

const `exampleSlackInfoWebhook` is unused (unused)

Check failure on line 26 in slack.go

View workflow job for this annotation

GitHub Actions / build (1.21)

const `exampleSlackInfoWebhook` is unused (unused)

Check failure on line 26 in slack.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] slack.go#L26

const `exampleSlackInfoWebhook` is unused (unused)
Raw output
slack.go:26:2: const `exampleSlackInfoWebhook` is unused (unused)
	exampleSlackInfoWebhook = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
	^
)
51 changes: 0 additions & 51 deletions slack_test.go

This file was deleted.

0 comments on commit 5d5da2c

Please sign in to comment.