zap icon indicating copy to clipboard operation
zap copied to clipboard

Refactor cloned logger variable names in Sugar and WithOptions

Open htoyoda18 opened this issue 4 months ago • 2 comments

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
}

htoyoda18 avatar Dec 07 '25 10:12 htoyoda18

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Dec 07 '25 10:12 CLAassistant

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 98.61%. Comparing base (7b755a3) to head (ad0cf92).

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           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Dec 08 '25 18:12 codecov[bot]