From d3055b9994b88519219253c3d4d4b0fead2abc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Cuadros?= Date: Mon, 25 Apr 2016 08:22:39 +0200 Subject: [PATCH] aliasing LogParts --- handler.go | 8 +++++--- handler_test.go | 3 +-- server.go | 2 +- server_test.go | 5 ++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/handler.go b/handler.go index f0ed73a..af5ec26 100644 --- a/handler.go +++ b/handler.go @@ -4,12 +4,14 @@ import ( "gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser" ) +type LogParts syslogparser.LogParts + //The handler receive every syslog entry at Handle method type Handler interface { - Handle(syslogparser.LogParts, int64, error) + Handle(LogParts, int64, error) } -type LogPartsChannel chan syslogparser.LogParts +type LogPartsChannel chan LogParts //The ChannelHandler will send all the syslog entries into the given channel type ChannelHandler struct { @@ -30,6 +32,6 @@ func (h *ChannelHandler) SetChannel(channel LogPartsChannel) { } //Syslog entry receiver -func (h *ChannelHandler) Handle(logParts syslogparser.LogParts, messageLength int64, err error) { +func (h *ChannelHandler) Handle(logParts LogParts, messageLength int64, err error) { h.channel <- logParts } diff --git a/handler_test.go b/handler_test.go index f0b3179..1427edb 100644 --- a/handler_test.go +++ b/handler_test.go @@ -2,7 +2,6 @@ package syslog import ( . "gopkg.in/check.v1" - "gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser" ) type HandlerSuite struct{} @@ -10,7 +9,7 @@ type HandlerSuite struct{} var _ = Suite(&HandlerSuite{}) func (s *HandlerSuite) TestHandle(c *C) { - logPart := syslogparser.LogParts{"tag": "foo"} + logPart := LogParts{"tag": "foo"} channel := make(LogPartsChannel, 1) handler := NewChannelHandler(channel) diff --git a/server.go b/server.go index d9df98f..0855f36 100644 --- a/server.go +++ b/server.go @@ -262,7 +262,7 @@ func (s *Server) parser(line []byte, client string, tlsPeer string) { } logParts["tls_peer"] = tlsPeer - s.handler.Handle(logParts, int64(len(line)), err) + s.handler.Handle(LogParts(logParts), int64(len(line)), err) } //Returns the last error diff --git a/server_test.go b/server_test.go index a8346d4..8100a22 100644 --- a/server_test.go +++ b/server_test.go @@ -8,7 +8,6 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser" ) func Test(t *testing.T) { TestingT(t) } @@ -51,12 +50,12 @@ func (s *ServerSuite) TestTailFile(c *C) { } type HandlerMock struct { - LastLogParts syslogparser.LogParts + LastLogParts LogParts LastMessageLength int64 LastError error } -func (s *HandlerMock) Handle(logParts syslogparser.LogParts, msgLen int64, err error) { +func (s *HandlerMock) Handle(logParts LogParts, msgLen int64, err error) { s.LastLogParts = logParts s.LastMessageLength = msgLen s.LastError = err