-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CBL-5396: Use os_log instead of NSLog for Console Log #3323
Open
velicuvlad
wants to merge
10
commits into
master
Choose a base branch
from
CBL-5396
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+53
−88
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ed9ecfb
move NSLog to os_log
velicuvlad 9a03db9
typo
velicuvlad a906642
change log to assert for inputWord
velicuvlad 6895ecd
changed to match .NET
velicuvlad c139662
Create generic internal logger for ConsoleLog
velicuvlad 4e50ac7
feedback
velicuvlad 90a540a
typo fix
velicuvlad e7defe8
fix framework id
velicuvlad 96a48a5
log under Database using specific call
velicuvlad 04526ca
plus 1
velicuvlad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
|
||
@implementation CBLConsoleLogger | ||
|
||
@synthesize level=_level, domains=_domains; | ||
@synthesize level=_level, domains=_domains, sysID=_sysID; | ||
|
||
static NSMutableDictionary<NSNumber *, os_log_t>* osLogDictionary; | ||
static os_log_t logger; | ||
|
@@ -32,6 +32,7 @@ - (instancetype) initWithLogLevel: (CBLLogLevel)level { | |
if (self) { | ||
_level = level; | ||
_domains = kCBLLogDomainAll; | ||
_sysID = [[NSBundle mainBundle] bundleIdentifier]; | ||
[self initializeOSLogDomains]; | ||
} | ||
return self; | ||
|
@@ -70,21 +71,22 @@ static os_log_type_t osLogTypeForLevel(CBLLogLevel level) { | |
|
||
- (void) initializeOSLogDomains { | ||
osLogDictionary = [NSMutableDictionary dictionary]; | ||
osLogDictionary[@(kCBLLogDomainDatabase)] = os_log_create("com.couchbase.lite.ios", "Database"); | ||
osLogDictionary[@(kCBLLogDomainQuery)] = os_log_create("com.couchbase.lite.ios", "Query"); | ||
osLogDictionary[@(kCBLLogDomainReplicator)] = os_log_create("com.couchbase.lite.ios", "Replicator"); | ||
osLogDictionary[@(kCBLLogDomainNetwork)] = os_log_create("com.couchbase.lite.ios", "Network"); | ||
|
||
osLogDictionary[@(kCBLLogDomainDatabase)] = os_log_create([self.sysID UTF8String], "Database"); | ||
osLogDictionary[@(kCBLLogDomainQuery)] = os_log_create([self.sysID UTF8String], "Query"); | ||
osLogDictionary[@(kCBLLogDomainReplicator)] = os_log_create([self.sysID UTF8String], "Replicator"); | ||
osLogDictionary[@(kCBLLogDomainNetwork)] = os_log_create([self.sysID UTF8String], "Network"); | ||
|
||
#ifdef COUCHBASE_ENTERPRISE | ||
osLogDictionary[@(kCBLLogDomainListener)] = os_log_create("com.couchbase.lite.ios", "Listener"); | ||
osLogDictionary[@(kCBLLogDomainListener)] = os_log_create([self.sysID UTF8String], "Listener"); | ||
#endif | ||
} | ||
|
||
+ (os_log_t) internalLogger { | ||
if(!logger){ | ||
logger = os_log_create("com.couchbase.lite.ios", "Log"); | ||
} | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
logger = os_log_create("com.couchbase.lite.ios", "Internal"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one still uses the hardcode string, "com.couchbase.lite.ios". |
||
}); | ||
return logger; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is right as it think it will return the bundle identifier of the app not the framework. What is the value when you run the test? If this returns bundle id of the app, you may try to get the bundle id from one of the classes such as CBLConsoleLogger itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, will fix