将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;
}
答案 0 :(得分:13)
我在组合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
}
答案 1 :(得分:5)
Swoud 3版本的Scoud解决方案:
static func hideGTMLogs() {
let tagClass: AnyClass? = NSClassFromString("TAGLogger")
let originalSelector = NSSelectorFromString("info:")
let detourSelector = #selector(AppDelegate.detour_info(message:))
guard let originalMethod = class_getClassMethod(tagClass, originalSelector),
let detourMethod = class_getClassMethod(AppDelegate.self, detourSelector) else { return }
class_addMethod(tagClass, detourSelector,
method_getImplementation(detourMethod), method_getTypeEncoding(detourMethod))
method_exchangeImplementations(originalMethod, detourMethod)
}
@objc
static func detour_info(message: String) {
return
}
答案 2 :(得分:1)
您没有指定语言。在您的情况下,警告级别似乎已经足够了。
// Optional: Change the LogLevel to Verbose to enable logging at VERBOSE and higher levels.
[self.tagManager.logger setLogLevel:kTAGLoggerLogLevelVerbose];
可用级别(docs):
来自官方文件: https://developers.google.com/tag-manager/ios/v3/#logger(已弃用,支持Firebase Analytics)
答案 3 :(得分:1)
经过大量挖掘,我设法找到了一种在Google跟踪代码管理器v7.0.0中禁用警告和错误日志(不幸的是不是信息日志)的方法。
下面的代码是用Swift 5编写的:
f
不透明指针的扩展名:
final TestDataModel dataModel = *save data in model*
dataModel .setRunnerBean("responseTaskRunner");
final TaskConditionModel conditionModel = modelService.create(TaskConditionModel.class);
final String uid = "Task" + System.currentTimeMillis();
conditionModel.setUniqueID(uid);
dataModel .setConditions(Collections.singleton(conditionModel));
// Start the task in 1 second
dataModel.setExecutionDate(new Date(System.currentTimeMillis() + 1000));
taskService.scheduleTask(gkaRequestBAPIdataModel);
taskService.triggerEvent(uid);