Skip to content

Commit

Permalink
Merge pull request #57 from mrpalide/fix/remove-syslog-codes
Browse files Browse the repository at this point in the history
Remove syslog
  • Loading branch information
mrpalide authored Mar 16, 2024
2 parents 177c854 + 662954c commit 0498a90
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 154 deletions.
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,5 @@ vendor-integration-check: ## Check compatibility of master@skywire-services with

## : ## _ [Other]

run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog
-mkdir -p /tmp/syslog
-docker container rm syslog-ng -f
docker run -d -p 514:514/udp -v /tmp/syslog:/var/log --name syslog-ng balabit/syslog-ng:latest

help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$|^##.*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 0 additions & 2 deletions cmd/address-resolver/address-resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import (
)

func init() {
var helpflag bool
commands.RootCmd.SetUsageTemplate(help)
commands.RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsgpty-cli")
commands.RootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
commands.RootCmd.PersistentFlags().MarkHidden("help") //nolint
}
Expand Down
12 changes: 0 additions & 12 deletions cmd/address-resolver/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

cc "github.com/ivanpirog/coloredcobra"
logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
"github.com/skycoin/dmsg/pkg/dmsghttp"
Expand Down Expand Up @@ -43,7 +41,6 @@ var (
metricsAddr string
redisURL string
redisPoolSize int
syslogAddr string
tag string
logLvl string
testing bool
Expand All @@ -60,7 +57,6 @@ func init() {
RootCmd.Flags().StringVar(&redisURL, "redis", "redis://localhost:6379", "connections string for a redis store\033[0m")
RootCmd.Flags().IntVar(&redisPoolSize, "redis-pool-size", 10, "redis connection pool size\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
RootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
RootCmd.Flags().StringVar(&tag, "tag", "address_resolver", "logging tag\033[0m")
RootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
RootCmd.Flags().StringVar(&dmsgDisc, "dmsg-disc", "http://dmsgd.skywire.skycoin.com", "url of dmsg-discovery\033[0m")
Expand Down Expand Up @@ -157,14 +153,6 @@ skywire svc ar --addr ":9093" --redis "redis://localhost:6379" --sk $(tail -n1 a
logger.WithError(err).Warn("No SecKey found. Skipping serving on dmsghttp.")
}

if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil && logger != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

metricsutil.ServeHTTPMetrics(logger, metricsAddr)

var m armetrics.Metrics
Expand Down
11 changes: 0 additions & 11 deletions cmd/dmsg-monitor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cipher"
"github.com/skycoin/skywire-utilities/pkg/cmdutil"
Expand All @@ -28,7 +26,6 @@ var (
utURL string
addr string
tag string
syslogAddr string
logLvl string
sleepDeregistration time.Duration
batchSize int
Expand All @@ -42,7 +39,6 @@ func init() {
RootCmd.Flags().StringVarP(&dmsgURL, "dmsg-url", "d", "", "url to dmsg data.\033[0m")
RootCmd.Flags().StringVarP(&utURL, "ut-url", "u", "", "url to uptime tracker visor data.\033[0m")
RootCmd.Flags().StringVar(&tag, "tag", "dmsg_monitor", "logging tag\033[0m")
RootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
}

Expand Down Expand Up @@ -88,13 +84,6 @@ var RootCmd = &cobra.Command{
srvURLs.UT = utURL

logger := mLogger.PackageLogger(tag)
if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

logger.WithField("addr", addr).Info("Serving DMSG-Monitor API...")

Expand Down
23 changes: 6 additions & 17 deletions cmd/liveness-checker/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cmdutil"
"github.com/skycoin/skywire-utilities/pkg/logging"
Expand All @@ -27,20 +25,18 @@ const (
)

var (
confPath string
addr string
tag string
syslogAddr string
logLvl string
redisURL string
testing bool
confPath string
addr string
tag string
logLvl string
redisURL string
testing bool
)

func init() {
RootCmd.Flags().StringVarP(&addr, "addr", "a", ":9081", "address to bind to.\033[0m")
RootCmd.Flags().StringVarP(&confPath, "config", "c", "liveness-checker.json", "config file location.\033[0m")
RootCmd.Flags().StringVar(&tag, "tag", "liveness_checker", "logging tag\033[0m")
RootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
RootCmd.Flags().StringVar(&redisURL, "redis", "redis://localhost:6379", "connections string for a redis store\033[0m")
RootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
Expand Down Expand Up @@ -91,13 +87,6 @@ var RootCmd = &cobra.Command{
conf, confAPI := api.InitConfig(confPath, mLogger)

logger := mLogger.PackageLogger(tag)
if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

ctx, cancel := cmdutil.SignalContext(context.Background(), logger)
defer cancel()
Expand Down
11 changes: 0 additions & 11 deletions cmd/network-monitor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cipher"
"github.com/skycoin/skywire-utilities/pkg/cmdutil"
Expand All @@ -38,7 +36,6 @@ var (
utURL string
addr string
tag string
syslogAddr string
logLvl string
metricsAddr string
redisURL string
Expand All @@ -56,7 +53,6 @@ func init() {
RootCmd.Flags().StringVarP(&arURL, "ar-url", "v", "", "url to address resolver.\033[0m")
RootCmd.Flags().StringVarP(&utURL, "ut-url", "u", "", "url to uptime tracker visor data.\033[0m")
RootCmd.Flags().StringVar(&tag, "tag", "network_monitor", "logging tag\033[0m")
RootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
RootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", "", "address to bind metrics API to\033[0m")
RootCmd.Flags().StringVar(&redisURL, "redis", "redis://localhost:6379", "connections string for a redis store\033[0m")
Expand Down Expand Up @@ -129,13 +125,6 @@ var RootCmd = &cobra.Command{
srvURLs.UT = utURL

logger := mLogger.PackageLogger("network_monitor")
if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

logger.WithField("addr", addr).Info("Serving discovery API...")

Expand Down
11 changes: 0 additions & 11 deletions cmd/node-visualizer/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"net/http"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cmdutil"
"github.com/skycoin/skywire-utilities/pkg/logging"
Expand All @@ -27,7 +25,6 @@ var (
addr string
metricsAddr string
logEnabled bool
syslogAddr string
tag string
testing bool
)
Expand All @@ -36,7 +33,6 @@ func init() {
RootCmd.Flags().StringVarP(&addr, "addr", "a", ":9081", "address to bind to\033[0m")
RootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", "", "address to bind metrics API to\033[0m")
RootCmd.Flags().BoolVarP(&logEnabled, "log", "l", true, "enable request logging\033[0m")
RootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
RootCmd.Flags().StringVar(&tag, "tag", "node-visualizer", "logging tag\033[0m")
RootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
}
Expand All @@ -63,13 +59,6 @@ var RootCmd = &cobra.Command{

const loggerTag = "node_visualizer"
logger := logging.MustGetLogger(loggerTag)
if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

metricsutil.ServeHTTPMetrics(logger, metricsAddr)

Expand Down
12 changes: 0 additions & 12 deletions cmd/route-finder/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
"github.com/skycoin/dmsg/pkg/dmsghttp"
Expand All @@ -35,7 +33,6 @@ var (
metricsAddr string
pgHost string
pgPort string
syslogAddr string
logLvl string
tag string
testing bool
Expand All @@ -49,7 +46,6 @@ func init() {
RootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", "", "address to bind metrics API to\033[0m")
RootCmd.Flags().StringVar(&pgHost, "pg-host", "localhost", "host of postgres\033[0m")
RootCmd.Flags().StringVar(&pgPort, "pg-port", "5432", "port of postgres\033[0m")
RootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
RootCmd.Flags().StringVar(&tag, "tag", "route_finder", "logging tag\033[0m")
RootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
Expand Down Expand Up @@ -121,14 +117,6 @@ PG_USER="postgres" PG_DATABASE="rf" PG_PASSWORD="" route-finder --addr ":9092"
logger.WithError(err).Warn("No SecKey found. Skipping serving on dmsghttp.")
}

if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil && logger != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

metricsutil.ServeHTTPMetrics(logger, metricsAddr)

var dmsgAddr string
Expand Down
12 changes: 0 additions & 12 deletions cmd/tpd-monitor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cipher"
"github.com/skycoin/skywire-utilities/pkg/cmdutil"
Expand All @@ -30,7 +28,6 @@ var (
addr string
logLvl string
tag string
syslogAddr string
sleepDeregistration time.Duration
)

Expand All @@ -43,7 +40,6 @@ func init() {
RootCmd.Flags().StringVar(&tpdURL, "tpd-url", "", "url to transport discovery.\033[0m")
RootCmd.Flags().StringVar(&arURL, "ar-url", "", "url to address resolver.\033[0m")
RootCmd.Flags().StringVar(&tag, "tag", "tpd-monitor", "logging tag\033[0m")
RootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
}

// RootCmd contains the root command
Expand Down Expand Up @@ -92,14 +88,6 @@ var RootCmd = &cobra.Command{
srvURLs.TPD = tpdURL
srvURLs.AR = arURL

if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

logger.WithField("addr", addr).Info("Serving TPD-Monitor API...")

monitorSign, _ := cipher.SignPayload([]byte(conf.PK.Hex()), conf.SK) //nolint
Expand Down
12 changes: 0 additions & 12 deletions cmd/transport-discovery/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
"github.com/skycoin/dmsg/pkg/dmsghttp"
Expand Down Expand Up @@ -45,7 +43,6 @@ var (
redisPoolSize int
pgHost string
pgPort string
syslogAddr string
logLvl string
tag string
testing bool
Expand All @@ -63,7 +60,6 @@ func init() {
RootCmd.Flags().IntVar(&redisPoolSize, "redis-pool-size", 10, "redis connection pool size\033[0m")
RootCmd.Flags().StringVar(&pgHost, "pg-host", "localhost", "host of postgres\033[0m")
RootCmd.Flags().StringVar(&pgPort, "pg-port", "5432", "port of postgres\033[0m")
RootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
RootCmd.Flags().StringVar(&tag, "tag", "transport_discovery", "logging tag\033[0m")
RootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
Expand Down Expand Up @@ -132,14 +128,6 @@ PG_USER="postgres" PG_DATABASE="tpd" PG_PASSWORD="" transport-discovery --sk $(t
api.WhitelistPKs.Set(v)
}

if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

var gormDB *gorm.DB

if !testing {
Expand Down
2 changes: 0 additions & 2 deletions internal/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ type ExternalServicesConfig struct {
RedisAddress string `json:"redis,omitempty"`
RedisCmd string `json:"redis_cmd,omitempty"`
MetricsAddress string `json:"metrics,omitempty"`
SyslogAddress string `json:"syslog,omitempty"`
SyslogCmd string `json:"syslog_cmd,omitempty"`
}

// RunnersConfig defines how each service is run
Expand Down
Loading

0 comments on commit 0498a90

Please sign in to comment.