diff options
author | 2021-12-12 18:00:20 +0100 | |
---|---|---|
committer | 2021-12-12 18:00:20 +0100 | |
commit | c111b239f7d102ac24a79fbef420af46dfec66f9 (patch) | |
tree | 813f5c4501a6e5048fb2922e099ce92d35b33b14 /vendor/gopkg.in/mcuadros/go-syslog.v2/handler.go | |
parent | add systemd service example to packaging (#342) (diff) | |
download | gotosocial-c111b239f7d102ac24a79fbef420af46dfec66f9.tar.xz |
Add optional syslog logrus hook (#343)
* add optional syslog logrus hook
* document syslog
Diffstat (limited to 'vendor/gopkg.in/mcuadros/go-syslog.v2/handler.go')
-rw-r--r-- | vendor/gopkg.in/mcuadros/go-syslog.v2/handler.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vendor/gopkg.in/mcuadros/go-syslog.v2/handler.go b/vendor/gopkg.in/mcuadros/go-syslog.v2/handler.go new file mode 100644 index 000000000..9914b3ea1 --- /dev/null +++ b/vendor/gopkg.in/mcuadros/go-syslog.v2/handler.go @@ -0,0 +1,35 @@ +package syslog + +import ( + "gopkg.in/mcuadros/go-syslog.v2/format" +) + +//The handler receive every syslog entry at Handle method +type Handler interface { + Handle(format.LogParts, int64, error) +} + +type LogPartsChannel chan format.LogParts + +//The ChannelHandler will send all the syslog entries into the given channel +type ChannelHandler struct { + channel LogPartsChannel +} + +//NewChannelHandler returns a new ChannelHandler +func NewChannelHandler(channel LogPartsChannel) *ChannelHandler { + handler := new(ChannelHandler) + handler.SetChannel(channel) + + return handler +} + +//The channel to be used +func (h *ChannelHandler) SetChannel(channel LogPartsChannel) { + h.channel = channel +} + +//Syslog entry receiver +func (h *ChannelHandler) Handle(logParts format.LogParts, messageLength int64, err error) { + h.channel <- logParts +} |