Add support for using HeliumLogger as a SwiftLog backend#73
Merged
djones6 merged 10 commits intoKitura:masterfrom Jul 18, 2019
Merged
Add support for using HeliumLogger as a SwiftLog backend#73djones6 merged 10 commits intoKitura:masterfrom
djones6 merged 10 commits intoKitura:masterfrom
Conversation
In SwiftLog 0, Logger.MetadataValue is not ExpressibleByStringLiteral or ExpressibleByStringInterpolation.
wlisac
commented
Jul 10, 2019
djones6
reviewed
Jul 15, 2019
djones6
reviewed
Jul 15, 2019
Contributor
Author
|
@djones6 Thanks for the review. I took a stab at addressing the feedback. Let me know if there's anything else you'd like adjusted. 🙂 |
Contributor
Author
|
I also just added a convenience API to bootstrap SwiftLog using HeliumLogger: HeliumLogger.bootstrapSwiftLog()You can optionally customize the default HeliumLogger.bootstrapSwiftLog { heliumLogger in
heliumLogger.colored = true
} |
Contributor
Author
|
@ianpartridge thanks for the review 👍 changes pushed. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds support for using HeliumLogger as a SwiftLog backend.
Description
Bootstrap SwiftLog
This makes it possible to bootstrap the SwiftLog logging system in a few different ways.
Convenience API
There is a convenience API to bootstrap SwiftLog using HeliumLogger.
You may optionally customize the default
HeliumLoggerinstance used with SwiftLog using a configuration closure.LoggingSystem API
You can bootstrap the SwiftLog logging system directly using a static factory method on
HeliumLogger.Alternatively, you can bootstrap using an existing
HeliumLoggerinstance. This allows for customization of theHeliumLoggerinstance.Using SwiftLog
Once the logging system is bootstrapped, you can use SwiftLog's
Loggeras usual andHeliumLoggerwill be used to generate the output.Example output:
Motivation and Context
SwiftLog is primarily an API package and needs SwiftLog-compatible logging backends.
From SwiftLog:
This adds a more mature logging backend to the SwiftLog ecosystem.
How Has This Been Tested?
I added an
XCTestCaseto test the SwiftLog implementation (TestSwiftLog.swift). These tests are primarily focused on exercising the new API and follows patterns fromTestLogger.swift.All tests are passing on macOS and Linux using Swift 4 and Swift 5 toolchains.
Impact on Existing Code
There are no source-breaking changes to the public API.
However, this does expand the surface area of the
HeliumLoggerAPI and introduces potential confusion by supporting two different logging APIs with inherent differences. For example:HeliumLoggerinstances may be initialized using aLoggerMessageTypethat is ignored when used with SwiftLog.HeliumLoggeris a class with reference semantics. SwiftLog expects aLoggerto have value semantics.Log segments were added to
HeliumLoggerthat are specific to SwiftLog (label/metadata).Longer term, it may make sense to create a generic logger package and provide separate packages for SwiftLog and LoggerAPI support, but this pull request aims to provide a much lower touch solution.
Overall, I'm hoping that the benefits of supporting the SwiftLog API are worth these tradeoffs.
Feedback welcome!
cc @ianpartridge @djones6