Skip to content

Commit

Permalink
move NSLog to os_log
Browse files Browse the repository at this point in the history
  • Loading branch information
velicuvlad committed Aug 19, 2024
1 parent c2e3d73 commit ed9ecfb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Objective-C/CBLConsoleLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ - (void) logWithLevel: (CBLLogLevel)level domain: (CBLLogDomain)domain message:

NSString* levelName = CBLLog_GetLevelName(level);
NSString* domainName = CBLLog_GetDomainName(domain);
NSLog(@"CouchbaseLite %@ %@: %@", domainName, levelName, message);
os_log_t log = os_log_create("CouchbaseLite", "OSDebug");
os_log(log, "CouchbaseLite %@ %@: %@", domainName, levelName, message);
}

@end
3 changes: 2 additions & 1 deletion Objective-C/CBLDatabase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ to be done in CBLInit()which is called only once when the first CBLDatabase is c
*/
+ (void) initialize {
if (self == [CBLDatabase class]) {
NSLog(@"%@", [CBLVersion userAgent]);
os_log_t log = os_log_create("CouchbaseLite", "OSLogging");
os_log(log, "%@", [CBLVersion userAgent]);
// Initialize logging
CBLAssertNotNil(CBLLog.sharedInstance);
}
Expand Down
1 change: 1 addition & 0 deletions Objective-C/CBLLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//

#import <Foundation/Foundation.h>
#import <os/log.h>

@protocol CBLLogger;
@class CBLConsoleLogger;
Expand Down
5 changes: 3 additions & 2 deletions Objective-C/CBLLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ - (instancetype) initWithDefault {
#ifdef DEBUG
// Check if user overrides the default callback log level:
NSString* userLogLevel = [NSUserDefaults.standardUserDefaults objectForKey: @"CBLLogLevel"];
os_log_t log = os_log_create("CouchbaseLite", "OSLogging");
if (userLogLevel) {
callbackLogLevel = string2level(userLogLevel);
}
if (callbackLogLevel != kC4LogWarning) {
NSLog(@"CouchbaseLite minimum log level is %s", kLevelNames[callbackLogLevel]);
os_log(log, "CouchbaseLite minimum log level is %s", kLevelNames[callbackLogLevel]);
}
#endif

Expand Down Expand Up @@ -190,7 +191,7 @@ - (instancetype) initWithDefault {
C4LogDomain domain = c4log_getDomain(domainName, true);
C4LogLevel level = string2level(defaults[key]);
c4log_setLevel(domain, level);
NSLog(@"CouchbaseLite logging to %s domain at level %s", domainName, kLevelNames[level]);
os_log(log, "CouchbaseLite logging to %s domain at level %s", domainName, kLevelNames[callbackLogLevel]);
}
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion Objective-C/Tests/Util/CBLWordEmbeddingModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ - (CBLDictionary*) predict: (CBLDictionary*)input {
NSString* inputWord = [input stringForKey: @"word"];

if (!inputWord) {
NSLog(@"No word input !!!");
os_log_t log = os_log_create("CouchbaseLite", "OSLogging");
os_log(log, "No word input !!!");
return nil;
}

Expand Down

0 comments on commit ed9ecfb

Please sign in to comment.