Write stderr on iPhone to both file and console

后端 未结 3 1483
醉话见心
醉话见心 2021-02-20 12:53

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 co

3条回答
  •  无人及你
    2021-02-20 13:11

    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
    }
    

    Thanks to Sailesh for that answer.

提交回复
热议问题