Skip to content

Commit d3055b9

Browse files
committed
aliasing LogParts
1 parent 280fd46 commit d3055b9

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

handler.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import (
44
"gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser"
55
)
66

7+
type LogParts syslogparser.LogParts
8+
79
//The handler receive every syslog entry at Handle method
810
type Handler interface {
9-
Handle(syslogparser.LogParts, int64, error)
11+
Handle(LogParts, int64, error)
1012
}
1113

12-
type LogPartsChannel chan syslogparser.LogParts
14+
type LogPartsChannel chan LogParts
1315

1416
//The ChannelHandler will send all the syslog entries into the given channel
1517
type ChannelHandler struct {
@@ -30,6 +32,6 @@ func (h *ChannelHandler) SetChannel(channel LogPartsChannel) {
3032
}
3133

3234
//Syslog entry receiver
33-
func (h *ChannelHandler) Handle(logParts syslogparser.LogParts, messageLength int64, err error) {
35+
func (h *ChannelHandler) Handle(logParts LogParts, messageLength int64, err error) {
3436
h.channel <- logParts
3537
}

handler_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package syslog
22

33
import (
44
. "gopkg.in/check.v1"
5-
"gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser"
65
)
76

87
type HandlerSuite struct{}
98

109
var _ = Suite(&HandlerSuite{})
1110

1211
func (s *HandlerSuite) TestHandle(c *C) {
13-
logPart := syslogparser.LogParts{"tag": "foo"}
12+
logPart := LogParts{"tag": "foo"}
1413

1514
channel := make(LogPartsChannel, 1)
1615
handler := NewChannelHandler(channel)

server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func (s *Server) parser(line []byte, client string, tlsPeer string) {
262262
}
263263
logParts["tls_peer"] = tlsPeer
264264

265-
s.handler.Handle(logParts, int64(len(line)), err)
265+
s.handler.Handle(LogParts(logParts), int64(len(line)), err)
266266
}
267267

268268
//Returns the last error

server_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"time"
99

1010
. "gopkg.in/check.v1"
11-
"gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser"
1211
)
1312

1413
func Test(t *testing.T) { TestingT(t) }
@@ -51,12 +50,12 @@ func (s *ServerSuite) TestTailFile(c *C) {
5150
}
5251

5352
type HandlerMock struct {
54-
LastLogParts syslogparser.LogParts
53+
LastLogParts LogParts
5554
LastMessageLength int64
5655
LastError error
5756
}
5857

59-
func (s *HandlerMock) Handle(logParts syslogparser.LogParts, msgLen int64, err error) {
58+
func (s *HandlerMock) Handle(logParts LogParts, msgLen int64, err error) {
6059
s.LastLogParts = logParts
6160
s.LastMessageLength = msgLen
6261
s.LastError = err

0 commit comments

Comments
 (0)