gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

handler.go (820B)


      1 package syslog
      2 
      3 import (
      4 	"gopkg.in/mcuadros/go-syslog.v2/format"
      5 )
      6 
      7 //The handler receive every syslog entry at Handle method
      8 type Handler interface {
      9 	Handle(format.LogParts, int64, error)
     10 }
     11 
     12 type LogPartsChannel chan format.LogParts
     13 
     14 //The ChannelHandler will send all the syslog entries into the given channel
     15 type ChannelHandler struct {
     16 	channel LogPartsChannel
     17 }
     18 
     19 //NewChannelHandler returns a new ChannelHandler
     20 func NewChannelHandler(channel LogPartsChannel) *ChannelHandler {
     21 	handler := new(ChannelHandler)
     22 	handler.SetChannel(channel)
     23 
     24 	return handler
     25 }
     26 
     27 //The channel to be used
     28 func (h *ChannelHandler) SetChannel(channel LogPartsChannel) {
     29 	h.channel = channel
     30 }
     31 
     32 //Syslog entry receiver
     33 func (h *ChannelHandler) Handle(logParts format.LogParts, messageLength int64, err error) {
     34 	h.channel <- logParts
     35 }