-
Notifications
You must be signed in to change notification settings - Fork 26
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
Adopt swift-log #46
Comments
A simple implementation that allows a swift-log Logger to be attached to LoggerAPI: https://github.com/djones6/LoggerAPI/tree/swift-log Sample project using the above: https://github.com/djones6/LoggingTest Some considerations for use of swift-log with LoggerAPI and/or Kitura:
|
We may want to provide an API on Kitura itself to set up swift-log, eg: |
Example updated to use Sample project updated using this: djones6/LoggingTest@40fdb1d |
@weissi ^^^ any thoughts? |
@djones6 / @ianpartridge I'm not sure I understand the question fully. Is the question on where/how to configure the |
Sorry, no particular question, just thought you might be interested to see @djones6's current direction on this, and might have comments! |
Thank you, that sounds great! I'll also have a look at the code now. |
@djones6 Thanks, that all looks really good. I left some comments, mostly that LoggerAPI isn't (and never was) thread-safe and I think there are some extra branches (on the log level) that we don't need. |
@weissi Thank you for your comments! I think it makes sense to address thread safety for both logging types. I'll work that up. |
312c0c8 adds locking. I left the (otherwise superfluous) log level checks in for now, as otherwise we'll lock regardless of whether the logger is going to log a message or ignore it, which would increase contention. That said, I haven't attempted to measure whether the cost of the check is less than the cost of (briefly) taking a lock - it feels like it should be. |
Thanks @weissi for your guidance on thread safety! I've reworked the locking changes to use computed properties incorporating As I was fearful of the performance overhead this might impose (as now, every LoggerAPI Log. call will go through a lock/unlock) I ran a Kitura hello-world test on Linux:
This was Kitura 2.7, Swift 5.0.1, on Ubuntu 16.04 (bare metal, affinitized to 4 CPUs). No measurable degradation, which is a good start! Now, on closer inspection there is currently only one log entry generated in a simple request path such as this, so the numbers may not be a big surprise, but it means we can be thread safe without regressing. |
Adding a reference to a newly created associated docs issue, so that we don't forget to update the docs once this is tagged in a release - Kitura/kitura.dev#367 |
https://github.com/apple/swift-log/tree/swift-log-0.0 supports Swift 4.1+
The text was updated successfully, but these errors were encountered: