Skip to content

Commit

Permalink
Log warning if path is set after instance is created
Browse files Browse the repository at this point in the history
  • Loading branch information
bamx23 committed Jun 25, 2024
1 parent ec9d76f commit 1cdd546
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/KSCrashRecording/KSCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ @interface KSCrash ()
@end

static NSString *gCustomBasePath = nil;
static BOOL gIsSharedInstanceCreated = NO;

static NSString* getBundleName(void)
{
Expand Down Expand Up @@ -129,6 +130,14 @@ + (void)initialize

+ (void) setBasePath:(NSString*) basePath;
{
if(basePath == gCustomBasePath || [basePath isEqualToString:gCustomBasePath])
{
return;
}
if(gIsSharedInstanceCreated)
{
KSLOG_WARN(@"A shared instance of KSCrash is already created. Can't change the base path to: %@", basePath);
}
gCustomBasePath = [basePath copy];
}

Expand All @@ -139,6 +148,7 @@ + (instancetype) sharedInstance

dispatch_once(&onceToken, ^{
sharedInstance = [[KSCrash alloc] initWithBasePath:getBasePath()];
gIsSharedInstanceCreated = YES;
});
return sharedInstance;
}
Expand Down

0 comments on commit 1cdd546

Please sign in to comment.