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

Implement scoped loggers from ModuleLoggers 🍰 #230

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

p4checo
Copy link
Member

@p4checo p4checo commented Apr 6, 2021

Checklist

Motivation and Context

On certain occasions, one needs to pass in a simple Logger instance but want log events forwarded to a larger logging infrastructure.

If we're dealing with a ModuleLogger with multiple registered modules, one may want to derive a simpler Logger that sends all events under a single module to the upstream logger. To achieve that, ModuleLogger can now create scoped loggers via a new scopedLogger(for:) helper.

Description

  • Create ModuleLogger.scopedLogger(for:) helper.

  • Create new Log.ForwardingLogger private helper class to forward log events to an upstream (Module) logger.

@p4checo p4checo requested a review from a team April 6, 2021 22:47
@codecov
Copy link

codecov bot commented Apr 6, 2021

Codecov Report

Merging #230 (650e291) into master (408a301) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #230   +/-   ##
=======================================
  Coverage   95.01%   95.02%           
=======================================
  Files          97       97           
  Lines        3289     3295    +6     
=======================================
+ Hits         3125     3131    +6     
  Misses        164      164           
Impacted Files Coverage Δ
Sources/Logging/Loggers/ModuleLogger.swift 100.00% <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 408a301...650e291. Read the comment docs.

On certain occasions, one needs to pass in a simple `Logger` instance
but want log events forwarded to a larger logging infrastructure.

If we're dealing with a `ModuleLogger` with multiple registered modules,
one may want to derive a simpler `Logger` that sends all events under a
single module to the upstream logger. To achieve that, `ModuleLogger`
can now create scoped loggers via a new `scopedLogger(for:)` helper.

## Changes

- Create `ModuleLogger.scopedLogger(for:)` helper.

- Create new `Log.ForwardingLogger` private helper class to forward log
events to an upstream (Module) logger.
@p4checo p4checo force-pushed the scoped-loggers-from-module-logger branch from 7ee0ea1 to 650e291 Compare April 8, 2021 14:50
@p4checo p4checo merged commit f8d9424 into master Apr 9, 2021
@p4checo p4checo deleted the scoped-loggers-from-module-logger branch April 9, 2021 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants