-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
RCOCOA-2273: Add support for Logger categories/ Improve current logger. #8608
base: master
Are you sure you want to change the base?
Conversation
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 don't see any reason for the obj-c code to be using strings for category names. There's a fixed set of them, so it can just be a (non-nested) enum.
RealmSwift/Logger.swift
Outdated
- parameter category: The log category for the message. | ||
- parameter message: The message to log. | ||
*/ | ||
internal func log(level: LogLevel, category: LogCategory = Category.realm, message: String) { |
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.
Why is this here?
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.
This is just makes it easier for us internally to log in the SDK side, we do have a category for this kind of logs Category.sdk in Swift
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.
There is also a category for app logs Category.app, so we could expose this to the user in that matters, but I agree that we don't need to expose this to the users and add noise to our logging mechanism, but I do agree that we could have some logging in the sdk side, we should discuss how granular we want this because we don't want to contaminate Core's log
1472ad6
to
02913a7
Compare
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.
The current logger implementation does not filter per category as per the documentation.
Realm/RLMLogger.mm
Outdated
} | ||
|
||
- (instancetype)initWithLevel:(RLMLogLevel)level | ||
category:(RLMLogCategory)category |
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.
The loggers created with this function are of the default category realm
. If you like to filter by category you might need to instantiate a Logger with the category.
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.
Changed the approach, and now you can only set the global log level for a category using setLogLevel. initWithLevel is gonna is deprecated
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.
LGTM
7a6d55f
to
ee66e9c
Compare
ee66e9c
to
fea2867
Compare
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.
Looks good - I only have minor comments/suggestions.
XCTAssertTrue(logs.value.contains("Transaction test entry")) | ||
logs.wrappedValue = "" | ||
|
||
logger.log(with: .info, categoryName: Category.realm.rawValue, message: "REALM test entry") |
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.
Why is this passing the raw category name rather than the LogCategory
?
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.
Because we cannot expose internal function to the test suite, instead we are using Realm.Private API to generate the logs for the tests
734224d
to
7c94c77
Compare
the log level for each category as well.
This has a proposal for the Categories enum which includes nested categories, for Objective-C we are using strings as it may be very complicated to have nested enums and it may be too mucho work for the number of users using Objective-C