Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Objective-C/CBLConsoleLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ @implementation CBLConsoleLogger
@synthesize level=_level, domains=_domains;

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

- (instancetype) initWithLogLevel: (CBLLogLevel)level {
self = [super init];
Expand Down Expand Up @@ -79,4 +80,17 @@ - (void) initializeOSLogDomains {
osLogDictionary[@(kCBLLogDomainListener)] = os_log_create("com.couchbase.lite.ios", "Listener");
#endif
}

+ (os_log_t) internalLogger {
if(!logger){
logger = os_log_create("com.couchbase.lite.ios", "Log");
}
return logger;
}

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

@end
3 changes: 1 addition & 2 deletions Objective-C/CBLDatabase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ to be done in CBLInit()which is called only once when the first CBLDatabase is c
*/
+ (void) initialize {
if (self == [CBLDatabase class]) {
os_log_t logger = os_log_create("com.couchbase.lite.ios", "UserAgent");
os_log(logger, "%@", [CBLVersion userAgent]);
[CBLConsoleLogger logWithInternal:[CBLVersion userAgent]];
// Initialize logging
CBLAssertNotNil(CBLLog.sharedInstance);
}
Expand Down
4 changes: 2 additions & 2 deletions Objective-C/CBLLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ - (instancetype) initWithDefault {
#ifdef DEBUG
// Check if user overrides the default callback log level:
NSString* userLogLevel = [NSUserDefaults.standardUserDefaults objectForKey: @"CBLLogLevel"];
oslogger = os_log_create("com.couchbase.lite.ios", "DebugBuild");
if (userLogLevel) {
callbackLogLevel = string2level(userLogLevel);
}
if (callbackLogLevel != kC4LogWarning) {
os_log(oslogger, "CouchbaseLite minimum log level is %s", kLevelNames[callbackLogLevel]);
NSString* message = [NSString stringWithFormat: @"CouchbaseLite minimum log level is %s", kLevelNames[callbackLogLevel]];
[CBLConsoleLogger logWithInternal: message];
}
#endif

Expand Down
4 changes: 4 additions & 0 deletions Objective-C/Internal/CBLLog+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype) initWithLogLevel: (CBLLogLevel)level;

+ (os_log_t) internalLogger;

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

@end

@interface CBLFileLogger ()
Expand Down
Loading