Skip to content

Commit

Permalink
impr: Remove not needed log for logging (getsentry#3934)
Browse files Browse the repository at this point in the history
Every log message needs to acquire a lock to evaluate whether the logger
should log it. getsentry#3303 added this logic to fix a data race the thread
sanitizer job found. As the SDK only calls the configure method when
starting, we don't need to put a synchronized keyword around the code
that evaluates the log level. This PR replaces the synchronized keyword
by ignoring the thread sanitizer.
  • Loading branch information
philipphofmann authored and Dipak Kasabwala committed May 6, 2024
1 parent 320e05b commit 879f3b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Ignore SentryFramesTracker thread sanitizer data races (#3922)
- Handle no releaseName in WatchDogTerminationLogic (#3919)

### Improvements

- Remove not needed lock for logging (#3934)

## 8.25.0

### Features
Expand Down
9 changes: 6 additions & 3 deletions Sources/Sentry/SentryLog.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "SentryLog.h"
#import "SentryInternalCDefines.h"
#import "SentryLevelMapper.h"
#import "SentryLogOutput.h"

Expand Down Expand Up @@ -37,10 +38,12 @@ + (void)logWithMessage:(NSString *)message andLevel:(SentryLevel)level
}

+ (BOOL)willLogAtLevel:(SentryLevel)level
SENTRY_DISABLE_THREAD_SANITIZER(
"The SDK usually configures the log level and isDebug once when it starts. For tests, we "
"accept a data race causing some log messages of the wrong level over using a synchronized "
"block for this method, as it's called frequently in production.")
{
@synchronized(logConfigureLock) {
return isDebug && level != kSentryLevelNone && level >= diagnosticLevel;
}
return isDebug && level != kSentryLevelNone && level >= diagnosticLevel;
}

// Internal and only needed for testing.
Expand Down

0 comments on commit 879f3b1

Please sign in to comment.