gpt4 book ai didi

ios - 如何从 os_log() 中查找源文件和行号

转载 作者:可可西里 更新时间:2023-11-01 03:31:33 35 4
gpt4 key购买 nike

Logging Apple reference对于 iOS 10 和 macOS Sierra 中的新日志系统,明确表示不包括行号和源文件信息,因为它是自动捕获的。

Don’t include symbolication information or source file line numbers in messages. The system automatically captures this information.

但我还没有找到任何方法来查看这些假定捕获的值。在控制台应用程序中,我可以看到子系统、类别、进程 ID 等,但没有关于文件和行的信息。

同样,命令行工具似乎缺少显示此信息的任何选项(除非我遗漏了什么)。

有人知道吗?

最佳答案

我认为它在 Swift 中还不可用,尽管您可以在终端中看到 C/C++ 中的文件和行号。参见 Apple 论坛 here .

我通过创建一个简单的命令行工具 Xcode 项目尝试了类似于论坛内部的东西:

import Foundation
import os.log

os_log("rrrr")

并在终端中输入以下内容:log stream --source --predicate 'eventMessage contains "rrrr"',我得到了这个:

Timestamp                       Thread     Type        Activity             PID    
2017-02-18 17:58:46.012381+0700 0x5067d Default 0x0 5637 <testLogSwift`_swift_os_log> rrrr

与我在 C/C++ 版本中得到的对比,它显示了文件和行号:

Timestamp                       Thread     Type        Activity             PID    
2017-02-18 17:55:05.056103+0700 0x4aa01 Default 0x0 5218 <testLogging`main (main.cpp:13)> qqq

关于ios - 如何从 os_log() 中查找源文件和行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40757530/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com