Skip to content

Commit

Permalink
fix(syslog): the syslog service cannot be started properly because it…
Browse files Browse the repository at this point in the history
… is unstable (#31)
  • Loading branch information
flc1125 authored Nov 16, 2023
1 parent 13c3411 commit 225e60d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
16 changes: 8 additions & 8 deletions log/syslog/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ type Logger struct {

var _ log.Logger = (*Logger)(nil)

func New(config *Config) (*Logger, error) {
s := &Logger{
func New(config *Config) *Logger {
return &Logger{
config: config,
}

if err := s.connect(); err != nil {
return nil, err
}

return s, nil
}

func (l *Logger) Log(level log.Level, keyvals ...interface{}) error {
if l.conn == nil {
if err := l.connect(); err != nil {
return err
}
}

if len(keyvals) == 0 {
return nil
}
Expand Down
13 changes: 6 additions & 7 deletions log/syslog/syslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
package syslog

import (
"runtime"
"testing"

"github.com/go-kratos/kratos/v2/log"
)

func TestSyslogLogger(t *testing.T) {
t.Skip("skip syslog test")
if runtime.GOOS == "windows" {
t.Skip("skip syslog test")
}

logger, err := New(&Config{
logger := New(&Config{
Network: "udp",
Addr: "192.168.8.92:30732",
Tag: "test",
})
defer logger.Close()

if err != nil {
t.Fatal(err)
}

err = logger.Log(log.LevelDebug, "test", "test")
err := logger.Log(log.LevelDebug, "test", "test")
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 225e60d

Please sign in to comment.