1 Star 0 Fork 2

Fengzhi/go-syslog

forked from menuiis/go-syslog 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
handler.go 824 Bytes
一键复制 编辑 原始数据 按行查看 历史
咏随风 提交于 2024-09-27 19:28 . 返回对象优化
package syslog
import (
"gitee.com/fengzhi_1/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
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fengzhi_1/go-syslog.git
git@gitee.com:fengzhi_1/go-syslog.git
fengzhi_1
go-syslog
go-syslog
f32490391394

搜索帮助