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

fix(conf): syslog win syntax error #2294

Merged
merged 1 commit into from
Oct 8, 2023
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
13 changes: 9 additions & 4 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,16 @@ func InitConf() {
if os.Getenv(logger.KuiperSyslogKey) == "true" || Config.Basic.Syslog != nil {
c := Config.Basic.Syslog
if c == nil {
c = &syslogConf{}
c = &syslogConf{
Enable: true,
}
}
err := logger.InitSyslog(c.Network, c.Address, c.Level, c.Tag)
if err != nil {
log.Fatal(err)
// Init when env is set OR enable is true
if c.Enable {
err := logger.InitSyslog(c.Network, c.Address, c.Level, c.Tag)
if err != nil {
log.Fatal(err)
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions internal/conf/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
)

var (
Log *logrus.Logger
LogFile *os.File
Log *logrus.Logger
LogFile *os.File
IsTesting bool
)

var IsTesting bool
const KuiperSyslogKey = "KuiperSyslogKey"

func init() {
InitLogger()
Expand Down
2 changes: 0 additions & 2 deletions internal/conf/logger/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
)

const KuiperSyslogKey = "KuiperSyslogKey"

func InitSyslog(network, address, level, tag string) error {
p := syslog.LOG_INFO
switch level {
Expand Down
1 change: 1 addition & 0 deletions internal/conf/logger/syslog_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ package logger

func InitSyslog(network, address, level, tag string) error {
Log.Warnf("Syslog is not supported on windows")
return nil
}