在iPhone上将stderr写入文件和控制台 [英] Write stderr on iPhone to both file and console

查看:59
本文介绍了在iPhone上将stderr写入文件和控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在此处用于将iOS设备上的NSLog输出重定向到文件,效果很好.问题在于它不再显示在设备的控制台中.我真正想要的是一种将stderr流发送到控制台和文件的方法.有人知道怎么做吗?

I'm following the suggestion in the answer here for redirecting NSLog output on an iOS device to a file, which works great. The problem is that it no longer shows up in the console on the device. What I'd really like is a way to tee the stderr stream to both the console and the file. Does anyone have an idea how to do that?

推荐答案

我在另一个线程上找到了可接受的答案(

I found an acceptable answer on another thread (NSLog() to both console and file).

此处提供的解决方案是仅在未检测到调试器的情况下才重定向到文件,如下所示:

The solution provided there is to only redirect to a file if a debugger is not detected, like this:

if (!isatty(STDERR_FILENO))
{
    // Redirection code
}

感谢塞里什的回答.

这篇关于在iPhone上将stderr写入文件和控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆