1 Star 0 Fork 0

Wsage/go-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
indicator_log.go 595 Bytes
一键复制 编辑 原始数据 按行查看 历史
sage 提交于 2022-01-15 10:58 . add metric
package metrics
import "log"
type LogIndicator struct {
label string
ch chan map[string]*IndicData
}
//指标上报器-日志
func NewLogIndicator(label string) *LogIndicator {
st := &LogIndicator{
label: label,
ch: make(chan map[string]*IndicData, 10),
}
go st.bgReport()
return st
}
func (l *LogIndicator) bgReport() {
for {
select {
case data := <-l.ch:
for _, v := range data {
log.Printf("[Statistical-%s]%s: %f %s", l.label, v.Name, v.Value, v.Unit)
}
}
}
}
//上报数据
func (l *LogIndicator) Report(data map[string]*IndicData) {
l.ch <- data
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/scottq/go-framework.git
git@gitee.com:scottq/go-framework.git
scottq
go-framework
go-framework
v1.1.37

搜索帮助