Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Discord start/stop logs #537

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/setup-node/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ var rootCmd = &cobra.Command{
if discordWebhookURL := discord.GetWebhookURLFromEnv(); discordWebhookURL != "" {
hook := discord.NewHook(tag, discordWebhookURL)
logging.AddHook(hook)

// Workaround for Discord logger hook. Actually, it's Info.
log.Error(discord.StartLogMessage)
defer log.Error(discord.StopLogMessage)
} else {
log.Info(discord.StartLogMessage)
defer log.Info(discord.StopLogMessage)
}

var rdr io.Reader
Expand Down
9 changes: 9 additions & 0 deletions cmd/skywire-visor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ var rootCmd = &cobra.Command{
Run: func(_ *cobra.Command, args []string) {
log := initLogger(tag, syslogAddr)

if discordWebhookURL := discord.GetWebhookURLFromEnv(); discordWebhookURL != "" {
// Workaround for Discord logger hook. Actually, it's Info.
log.Error(discord.StartLogMessage)
defer log.Error(discord.StopLogMessage)
} else {
log.Info(discord.StartLogMessage)
defer log.Info(discord.StopLogMessage)
}

delayDuration, err := time.ParseDuration(delay)
if err != nil {
log.WithError(err).Error("Failed to parse delay duration.")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ require (
)

// Uncomment for tests with alternate branches of 'dmsg'
//replace github.com/skycoin/dmsg => ../dmsg
replace github.com/skycoin/dmsg => ../dmsg
3 changes: 2 additions & 1 deletion vendor/github.com/skycoin/dmsg/cmdutil/service_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 0 additions & 31 deletions vendor/github.com/skycoin/dmsg/discord/discord.go

This file was deleted.

98 changes: 98 additions & 0 deletions vendor/github.com/skycoin/dmsg/discord/hook.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ github.com/shirou/gopsutil/process
## explicit
github.com/sirupsen/logrus
github.com/sirupsen/logrus/hooks/syslog
# github.com/skycoin/dmsg v0.0.0-20200922082251-01fafc6408e7
# github.com/skycoin/dmsg v0.0.0-20200922082251-01fafc6408e7 => ../dmsg
## explicit
github.com/skycoin/dmsg
github.com/skycoin/dmsg/buildinfo
Expand Down Expand Up @@ -319,3 +319,4 @@ nhooyr.io/websocket/internal/bpool
nhooyr.io/websocket/internal/errd
nhooyr.io/websocket/internal/wsjs
nhooyr.io/websocket/internal/xsync
# github.com/skycoin/dmsg => ../dmsg