1 Star 0 Fork 0

litian/machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
history_recorder.go 646 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jean-Laurent de Morlhon 提交于 2015-12-16 16:35 . Extract Recording Code
package log
import (
"fmt"
"sync"
)
type HistoryRecorder struct {
lock *sync.Mutex
records []string
}
func NewHistoryRecorder() *HistoryRecorder {
return &HistoryRecorder{
lock: &sync.Mutex{},
records: []string{},
}
}
func (ml *HistoryRecorder) History() []string {
return ml.records
}
func (ml *HistoryRecorder) Record(args ...interface{}) {
ml.lock.Lock()
defer ml.lock.Unlock()
ml.records = append(ml.records, fmt.Sprint(args...))
}
func (ml *HistoryRecorder) Recordf(fmtString string, args ...interface{}) {
ml.lock.Lock()
defer ml.lock.Unlock()
ml.records = append(ml.records, fmt.Sprintf(fmtString, args...))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/litian33/machine.git
git@gitee.com:litian33/machine.git
litian33
machine
machine
v0.15.0-rancher5

搜索帮助

0d507c66 1850385 C8b1a773 1850385