问题描述
Logrus 按字母顺序记录键,这是我想要和需要的,但我想编写一个测试以确保它没有改变,我尝试添加钩子,但我认为我无法访问完整日志使用我使用 fuzzyJoinFunction<-function(a){
a<-fuzzy_left_join(a,Experiment_List,by = c('Dev.Date.Time' = 'StartTime','Dev.Date.Time'= 'StopTime'),match_fun = c(`>=`,`<=`))
a
}
df<-rbindlist(mclapply(X=df,FUN=fuzzyJoinFunction,mc.cores=4))
添加的自定义上下文,我只能获取消息记录示例
WithFields
我想测试 func TestSomething(t*testing.T){
logger,hook := test.NewNullLogger()
logger.WithField("correlationId","123").WithField("id","1").Info("hello")
assert.Equal(t,1,len(hook.Entries))
assert.Equal(t,logrus.(Level,hook.LastEntry().Level)
assert.Equal(t,"Hello",hook.LastEntry().Message)
hook.Reset()
assert.Nil(t,hook.LastEntry())
}
在输出中出现在 message
之前
t
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)