Skip to content

Commit

Permalink
Merge pull request #537 from nkryuchkov/feature/discord-start-stop-logs
Browse files Browse the repository at this point in the history
Add Discord start/stop logs
  • Loading branch information
nkryuchkov authored Oct 8, 2020
2 parents 397ea24 + f07b606 commit 6c30a30
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 36 deletions.
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

0 comments on commit 6c30a30

Please sign in to comment.