1 Star 1 Fork 1

menuiis / go-syslog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
handler.go 817 Bytes
一键复制 编辑 原始数据 按行查看 历史
menuis 提交于 2023-10-27 15:25 . init
package syslog
import (
"gitee.com/menciis/go-syslog/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
}
1
https://gitee.com/menciis/go-syslog.git
git@gitee.com:menciis/go-syslog.git
menciis
go-syslog
go-syslog
1eade08173b3

搜索帮助