将 Google 跟踪代码管理器添加到项目后,我在控制台中看到了很多日志条目。有办法禁用它吗?控制台日志充满了噪音:
GoogleTagManager info: Processing logged event: _vs with parameters: {
"_o" = auto;
"_pc" = UIViewController;
"_pi" = "-3988739357756819671";
"_sc" = "Bubbie.MamboBamboViewController";
"_si" = "-3988739357756819670";
}
2017-07-27 12:01:09.744 BubbieHuff[77205:6894827] GoogleTagManager info: Processing logged event: show_view with parameters: {
"_sc" = "Bubbie.MamboBamboViewController";
"_si" = "-3988739357756819670";
name = Mambo;
}
我刚刚在一个结合了 Google 跟踪代码管理器和 Firebase 的项目中遇到了这个问题。由于没有公开有关日志记录的标头,我找不到将其关闭的方法。
这是我想出的一个猴子补丁,可以让你控制来自 GTM 的信息日志。
+ (void)patchGoogleTagManagerLogging {
Class class = NSClassFromString(@"TAGLogger");
SEL originalSelector = NSSelectorFromString(@"info:");
SEL detourSelector = @selector(detour_info:);
Method originalMethod = class_getClassMethod(class, originalSelector);
Method detourMethod = class_getClassMethod([self class], detourSelector);
class_addMethod(class,
detourSelector,
method_getImplementation(detourMethod),
method_getTypeEncoding(detourMethod));
method_exchangeImplementations(originalMethod, detourMethod);
}
+ (void)detour_info:(NSString*)message {
return; // Disable logging
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)