Skip to content

Refactor cloned logger variable names in Sugar and WithOptions - #1523

Open
htoyoda18 wants to merge 1 commit into
uber-go:masterfrom
htoyoda18:refacto/variable-name
Open

Refactor cloned logger variable names in Sugar and WithOptions#1523
htoyoda18 wants to merge 1 commit into
uber-go:masterfrom
htoyoda18:refacto/variable-name

Conversation

@htoyoda18

Copy link
Copy Markdown

Summary

This refactors local variable names in Logger.Sugar and Logger.WithOptions to better reflect their actual type and usage.

Previously, the cloned *Logger instance was stored in variables named core and c, which can be misleading because:

  • core suggests a zapcore.Core rather than a *Logger
  • c is not very descriptive in this context

Now both methods consistently use l (for logger) as the local variable name.

Changes

func (log *Logger) Sugar() *SugaredLogger {
-   core := log.clone()
-   core.callerSkip += 2
-   return &SugaredLogger{core}
+   l := log.clone()
+   l.callerSkip += 2
+   return &SugaredLogger{l}
}

func (log *Logger) WithOptions(opts ...Option) *Logger {
-   c := log.clone()
-   for _, opt := range opts {
-       opt.apply(c)
-   }
-   return c
+   l := log.clone()
+   for _, opt := range opts {
+       opt.apply(l)
+   }
+   return l
}

@CLAassistant

CLAassistant commented Dec 7, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@htoyoda18
htoyoda18 marked this pull request as ready for review December 7, 2025 10:51
@codecov

codecov Bot commented Dec 8, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.61%. Comparing base (7b755a3) to head (ad0cf92).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1523   +/-   ##
=======================================
  Coverage   98.61%   98.61%           
=======================================
  Files          53       53           
  Lines        3033     3033           
=======================================
  Hits         2991     2991           
  Misses         34       34           
  Partials        8        8           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants