如何在Xcode控制台中禁用os_log_info和os_log_debug消息? [英] How do you disable os_log_info and os_log_debug messages in Xcode console?

查看:316
本文介绍了如何在Xcode控制台中禁用os_log_info和os_log_debug消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于记录的现代API可以在终端中轻松配置.但是,Xcode似乎输出所有级别,包括INFO和DEBUG,这非常令人讨厌.因为大多数时候您只想看到os_log_errorNSLog又名出了点问题"和这很重要".

Modern API for Logging is easy configurable in Terminal. However, Xcode seems to output all levels including INFO and DEBUG which is very annoying. Because most of the time you want to see only os_log_error and NSLog aka "something went wrong" and "this is important".

那么有什么方法可以在Xcode Console中仅显示特定级别?

So is there any way to display only particular levels in Xcode Console?

os_log_info(OS_LOG_DEFAULT, "Info");
os_log_debug(OS_LOG_DEFAULT, "Debug");
os_log_error(OS_LOG_DEFAULT, "Error");
os_log_fault(OS_LOG_DEFAULT, "Fault");
os_log(OS_LOG_DEFAULT, "Default");
NSLog(@"NSLog");

当前输出:

2016-12-14 15:37:00.170807 Test[5681:2205834] Info
2016-12-14 15:37:00.170830 Test[5681:2205834] Debug
2016-12-14 15:37:00.170835 Test[5681:2205834] Error
2016-12-14 15:37:00.170839 Test[5681:2205834] Fault
2016-12-14 15:37:00.170860 Test[5681:2205834] Default
2016-12-14 15:37:00.170869 Test[5681:2205834] NSLog

首选输出:

2016-12-14 15:37:00.170835 Test[5681:2205834] Error
2016-12-14 15:37:00.170839 Test[5681:2205834] Fault
2016-12-14 15:37:00.170860 Test[5681:2205834] Default
2016-12-14 15:37:00.170869 Test[5681:2205834] NSLog

推荐答案

我使用了DTS,并从Apple工程师那里得到了答案:

I have used DTS and got the answer from an Apple engineer:

新的统一日志记录系统是相对较新的功能,可惜Xcode尚未赶上它.如果您希望看到将来版本的Xcode支持日志过滤功能,建议您提出描述您的要求的增强功能请求.

The new unified logging system is a relatively recent addition and, alas, Xcode has not yet caught up with it. If you'd like to see a future version of Xcode support log filtering, I encourage you to file an enhancement request describing your requirements.

因此,请重复rdar://28288063,请求越多越好.谢谢!

So please duplicate rdar://28288063, the more requests the better. Thanks!

更新:如下面的"Max"所述,您可以修改自定义日志的可见性:

Update: As noted by Max below, you can modify visibility for custom logs:

os_log_t custom = os_log_create("com.acme.demo", "custom");
os_log_info(custom, "Info");
os_log_debug(custom, "Debug");
os_log_error(custom, "Error");
os_log_fault(custom, "Fault");
os_log(custom, "Default");

以下 Terminal 命令将取消 Xcode 中的"Info"和"Debug"字符串:

The following Terminal command will suppress "Info" and "Debug" strings in Xcode:

sudo log config --mode "level:default" --subsystem "com.acme.demo"

要重置系统默认值,请执行以下操作:

To reset system defaults:

sudo log config -reset --subsystem "com.acme.demo"

要检查当前状态:

sudo log config --subsystem "com.acme.demo"

这篇关于如何在Xcode控制台中禁用os_log_info和os_log_debug消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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