Skip to content

Commit

Permalink
log under Database using specific call
Browse files Browse the repository at this point in the history
  • Loading branch information
velicuvlad committed Oct 22, 2024
1 parent e7defe8 commit 96a48a5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
14 changes: 2 additions & 12 deletions Objective-C/CBLConsoleLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ @implementation CBLConsoleLogger
@synthesize level=_level, domains=_domains;

static NSMutableDictionary<NSNumber *, os_log_t>* osLogDictionary;
static os_log_t logger;
static NSString* _sysID;

- (instancetype) initWithLogLevel: (CBLLogLevel)level {
Expand Down Expand Up @@ -83,17 +82,8 @@ - (void) initializeOSLogDomains {
#endif
}

+ (os_log_t) internalLogger {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
logger = os_log_create([_sysID UTF8String], "Internal");
});
return logger;
}

+ (void) logWithInternal: (NSString*)message {
logger = [self internalLogger];
os_log(logger, "%@", message);
+ (void) logAlways: (NSString*)message {
os_log(osLogDictionary[@(kCBLLogDomainDatabase)], "%@", message);
}

@end
2 changes: 1 addition & 1 deletion Objective-C/CBLDatabase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ + (void) initialize {
+ (void) CBLInit {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[CBLConsoleLogger logWithInternal:[CBLVersion userAgent]];
[CBLConsoleLogger logAlways:[CBLVersion userAgent]];
[self checkFileLogging];
});
}
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/CBLLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ - (instancetype) initWithDefault {
}
if (callbackLogLevel != kC4LogWarning) {
NSString* message = [NSString stringWithFormat: @"CouchbaseLite minimum log level is %s", kLevelNames[callbackLogLevel]];
[CBLConsoleLogger logWithInternal: message];
[CBLConsoleLogger logAlways: message];
}
#endif

Expand Down
4 changes: 1 addition & 3 deletions Objective-C/Internal/CBLLog+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype) initWithLogLevel: (CBLLogLevel)level;

+ (os_log_t) internalLogger;

+ (void) logWithInternal: (nonnull NSString*)message;
+ (void) logAlways: (nonnull NSString*)message;

@end

Expand Down

0 comments on commit 96a48a5

Please sign in to comment.