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

Move logger into context #208

Merged
merged 1 commit into from Apr 18, 2022
Merged

Move logger into context #208

merged 1 commit into from Apr 18, 2022

Conversation

scothis
Copy link
Contributor

@scothis scothis commented Apr 18, 2022

The logger was previously available on the Config object as well as from
the context via logr.FromContext(ctx). While they are the same root
logger, each has a different set of names and values applied to each log
line.

Loading the logger from the context is the preferred approach moving
forward. The logger on the Config is still available, but is deprecated
and will be removed in a future release. The first use of the c.Log
methods will trigger an error printed to the log.

Each reconciler in the call chain can enrich the logger as it is passed
deeper in the reconciler hierarchy. Many reconciler have a new Name
field that is appended to the logger's name for all log statements under
it. ParentReconciler, ChildReconciler and CastParent provide
default names based on the type they are reconciling. Unique names are
recommended, but are not required, since they only appear in logs and do
not affect the runtime behavior.

Signed-off-by: Scott Andrews andrewssc@vmware.com

@codecov
Copy link

codecov bot commented Apr 18, 2022

Codecov Report

Merging #208 (c7d3990) into main (d3021c6) will decrease coverage by 3.59%.
The diff coverage is 36.55%.

❗ Current head c7d3990 differs from pull request most recent head 7c7dad4. Consider uploading reports for the commit 7c7dad4 to get more accurate results

@@            Coverage Diff             @@
##             main     #208      +/-   ##
==========================================
- Coverage   64.71%   61.11%   -3.60%     
==========================================
  Files           8        9       +1     
  Lines         768      841      +73     
==========================================
+ Hits          497      514      +17     
- Misses        256      310      +54     
- Partials       15       17       +2     
Impacted Files Coverage Δ
reconcilers/enqueuer.go 0.00% <0.00%> (ø)
reconcilers/logger.go 0.00% <0.00%> (ø)
reconcilers/reconcilers.go 80.47% <52.30%> (-4.53%) ⬇️

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 d3021c6...7c7dad4. Read the comment docs.

The logger was previously available on the Config object as well as from
the context via `logr.FromContext(ctx)`. While they are the same root
logger, each has a different set of names and values applied to each log
line.

Loading the logger from the context is the preferred approach moving
forward. The logger on the Config is still available, but is deprecated
and will be removed in a future release. The first use of the `c.Log`
methods will trigger an error printed to the log.

Each reconciler in the call chain can enrich the logger as it is passed
deeper in the reconciler hierarchy. Many reconciler have a new `Name`
field that is appended to the logger's name for all log statements under
it. `ParentReconciler`, `ChildReconciler` and `CastParent` provide
default names based on the type they are reconciling. Unique names are
recommended, but are not required, since they only appear in logs and do
not affect the runtime behavior.

Signed-off-by: Scott Andrews <andrewssc@vmware.com>
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.

None yet

2 participants