Skip to main content

Privacy and console logs

note

Looking for the previous SDK? See the 6.x console logs privacy page.

Bugsee captures your application's console logs automatically: standard output and standard error (print, NSLog), CocoaLumberjack, the console of web pages in a WKWebView, and the console output that the React Native, Flutter and Unity SDKs forward. You can turn the capture off, keep only the more important levels, or clean every line before it is recorded.

Disabling log capture​

Set BugseeOptionCaptureLogs (BugseeOptions.captureLogs) to NO. Nothing is captured automatically then. Lines your code sends with Bugsee.log are still recorded.

BugseeOptions *options = [BugseeOptions defaultOptions];
options.captureLogs = NO;

[Bugsee launchWithToken:@"<your_app_token>" options:options];

Keeping only some levels​

BugseeOptionCaptureLogsLevel takes a BugseeLogLevel and drops every line more verbose than it. The default, BugseeLogLevelVerbose, keeps everything; BugseeLogLevelWarning keeps warnings and errors only. The level is applied before your filter, so the filter never sees the dropped lines.

[Bugsee launchWithToken:@"<your_app_token>" andOptions:@{
BugseeOptionCaptureLogsLevel : @(BugseeLogLevelWarning),
}];

Filtering logs​

A log filter receives every line before it is recorded, as a BugseeLogEvent. Change its text (or its level, subsystem and category) and pass it to the decision block, or pass nil to drop the line. A line whose text you set to an empty string is dropped too.

Set the filter with a block:

NSRegularExpression *regex =
[NSRegularExpression regularExpressionWithPattern:@"access_token=[0-9a-z\\-]*"
options:NSRegularExpressionCaseInsensitive
error:nil];

[Bugsee setLogEventFilter:^(BugseeLogEvent *event, BugseeLogFilterDecisionBlock decision) {
if ([event.text containsString:@"password"]) {
decision(nil); // drop the line
return;
}
event.text = [regex stringByReplacingMatchesInString:event.text
options:0
range:NSMakeRange(0, event.text.length)
withTemplate:@"access_token=<redacted>"];
decision(event);
}];

// Remove the filter
[Bugsee setLogEventFilter:nil];

Or implement the filter in your BugseeDelegate:

- (void)bugseeFilterLog:(BugseeLogEvent *)log
completionHandler:(BugseeLogFilterDecisionBlock)decisionBlock {
if ([log.text containsString:@"password"]) {
decisionBlock(nil);
return;
}
decisionBlock(log);
}

// ...somewhere within the class
[Bugsee sharedInstance].delegate = self;
  • If both are set, the block filter is used and the delegate method is not called.
  • Call the decision block once, within 10 seconds. Past that the line is dropped, and a later call is ignored. The filter may finish on any thread.
  • Lines sent with Bugsee.log skip the filter, because your code wrote them. To run such a line through the filter, send it with log:level:requiresFiltering: and requiresFiltering set to YES:
[Bugsee log:message level:BugseeLogLevelInfo requiresFiltering:YES];

More about console logs: Console logs.

Found an issue, typo, or wrong statement on this page? Report it now →