Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何混合鞭打和停止_R_Logging_Error Handling - Fatal编程技术网

R 如何混合鞭打和停止

R 如何混合鞭打和停止,r,logging,error-handling,R,Logging,Error Handling,我开始使用这个软件包了。有一个很好的致命错误日志,我想与stop结合使用。 但我要说: stop(flog.fatal('crash for some reason')) 我明白了 [FATAL] [2015-07-06 22:46:54] [base.stop] crash for some reason Error: [FATAL] [2015-07-06 22:46:54] [base.stop] crash for some reason 在记录了flog.fatal记录的内容之

我开始使用这个软件包了。有一个很好的致命错误日志,我想与
stop
结合使用。 但我要说:

stop(flog.fatal('crash for some reason'))
我明白了

[FATAL] [2015-07-06 22:46:54] [base.stop] crash for some reason

Error: 
[FATAL] [2015-07-06 22:46:54] [base.stop] crash for some reason
在记录了
flog.fatal
记录的内容之后,我如何停止(中止程序)


所以,你说的问题似乎无关紧要?照办

flog.fatal('crash for some reason'); stop()
?

(我个人认为,在将文本消息写入文件(而不是控制台)时,votile.logger更有用,它还可以在R的条件下将消息打印到控制台
message()、warning()、stop()

flog.fatal返回的值是停止打印的字符向量(长度1)

res <- flog.fatal('crash for some reason')
print(res)

res作为替代方案,您可以使用
futile.logger
软件包中的
ftry
功能

> futile.logger::ftry(log("a"))
ERROR [2017-08-22 10:50:51] non-numeric argument to mathematical function
Error in log("a") : non-numeric argument to mathematical function
R> flog.fatal(‘因某种原因崩溃’);stop()fatal[2017-08-22 03:16:33]因某种原因崩溃错误:(这与仅flog消息不同)