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 all 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 @@ -21,7 +21,7 @@ require (
github.com/schollz/progressbar/v2 v2.15.0
github.com/shirou/gopsutil v2.20.5+incompatible
github.com/sirupsen/logrus v1.6.0
github.com/skycoin/dmsg v0.0.0-20200922082251-01fafc6408e7
github.com/skycoin/dmsg v0.0.0-20201008074402-acbe6d76d785
github.com/skycoin/skycoin v0.26.0
github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/skycoin/dmsg v0.0.0-20200922082251-01fafc6408e7 h1:8MLQ7JNk54C34lwZns1b60UTlr5kGWe6SLIxT18eBIk=
github.com/skycoin/dmsg v0.0.0-20200922082251-01fafc6408e7/go.mod h1:xkd4GkAkPfwbbBDyp6rJoUWjPaV/Jj4bxAhsMTKO7ck=
github.com/skycoin/dmsg v0.0.0-20201008074402-acbe6d76d785 h1:wO5+dExw3a+eNPQk6cCPZnEP5P1KxBafADeWZEFQCrY=
github.com/skycoin/dmsg v0.0.0-20201008074402-acbe6d76d785/go.mod h1:xkd4GkAkPfwbbBDyp6rJoUWjPaV/Jj4bxAhsMTKO7ck=
github.com/skycoin/skycoin v0.26.0 h1:xDxe2r8AclMntZ550Y/vUQgwgLtwrf9Wu5UYiYcN5/o=
github.com/skycoin/skycoin v0.26.0/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw=
github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f h1:A5dEM1OE9YhN3LciZU9qPjo7fJ46JeHNi3JCroDkK0Y=
Expand Down
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.

100 changes: 100 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.

2 changes: 1 addition & 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-20201008074402-acbe6d76d785
## explicit
github.com/skycoin/dmsg
github.com/skycoin/dmsg/buildinfo
Expand Down