Skip to content
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

Improve Logger experience #1522

Merged
merged 1 commit into from Oct 13, 2021
Merged

Improve Logger experience #1522

merged 1 commit into from Oct 13, 2021

Conversation

b-onc
Copy link
Contributor

@b-onc b-onc commented Oct 6, 2021

  • LogConfig changes will now re-create Logger
  • Introducing subsystems to allow finer control in logging

15 minute break PR since I got fed up with uninformative flood of Database log messages. This is used as:

LogConfig.subsystems = .all.subtracting(.database)

The subsystem definition is open for discussion, manually specifying subsystems seems like to lot of burden for developers to not forget. Alternative would be injecting a Logger instance, which required more changes.

Copy link
Contributor

@evsaev evsaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid breaking changes coming from LogDestination and we are good! Great job 👏

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Sources/StreamChat/Utils/Logger/Logger.swift Show resolved Hide resolved
@@ -66,11 +69,17 @@ open class BaseLogDestination: LogDestination {
self.showFunctionName = showFunctionName
}

/// Checks if this destination is enabled for the given level
open func isEnabled(level: LogLevel) -> Bool {
assertionFailure("`isEnabled(level:)` is deprecated, please use `isEnabled(level:subsystem:)`")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We preserved the APIs but if customers call super.isEnabled(level) they'll see a crash when running the app in DEBUG, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, they'll immediately spot the crash though

evsaev
evsaev previously approved these changes Oct 12, 2021
Copy link
Contributor

@evsaev evsaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

- LogConfig changes will now re-create Logger
- Introducing `subsystems` to allow finer control in logging
@codecov
Copy link

codecov bot commented Oct 13, 2021

Codecov Report

Merging #1522 (5689802) into main (4bda933) will decrease coverage by 0.42%.
The diff coverage is 51.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1522      +/-   ##
==========================================
- Coverage   88.32%   87.89%   -0.43%     
==========================================
  Files         231      232       +1     
  Lines       10850    10950     +100     
==========================================
+ Hits         9583     9625      +42     
- Misses       1267     1325      +58     
Flag Coverage Δ
llc-tests 87.89% <51.35%> (-0.43%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...Chat/Utils/Logger/Destination/LogDestination.swift 0.00% <0.00%> (ø)
Sources/StreamChat/APIClient/APIClient.swift 75.72% <33.33%> (ø)
Sources/StreamChat/Utils/Logger/Logger.swift 62.80% <44.89%> (-24.54%) ⬇️
Sources/StreamChat/APIClient/CDNClient.swift 78.84% <50.00%> (ø)
Sources/StreamChat/APIClient/RequestDecoder.swift 65.11% <50.00%> (-0.74%) ⬇️
.../Utils/Logger/Destination/BaseLogDestination.swift 74.46% <50.00%> (-4.61%) ⬇️
...s/StreamChat/WebSocketClient/WebSocketClient.swift 89.60% <50.00%> (ø)
...ources/StreamChat/Database/DatabaseContainer.swift 96.45% <90.00%> (+0.02%) ⬆️
Sources/StreamChat/APIClient/RequestEncoder.swift 92.36% <90.90%> (+0.30%) ⬆️
...ocketClient/Engine/URLSessionWebSocketEngine.swift 58.33% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4bda933...5689802. Read the comment docs.

@b-onc b-onc merged commit b286bb4 into main Oct 13, 2021
@b-onc b-onc deleted the logger-improvements branch October 13, 2021 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants