refactor: remove package-level loggers, thread via struct fields and context - #29
Merged
Merged
Conversation
…context - Delete internal/log package (abtrlog); inline setup logic into arbiter.go as a setupLoggers() helper function - Add logger logr.Logger field to abtr struct; populate from Run() - Convert standalone startModules() to method on abtr - Change setupReporter() to return (report.Reporter, error) and pass a.logger to the yaml reporter - Fix defaultOpts() bug: was setting InfoLogPath twice, never ErrorLogPath - yamlreport.New() now returns (report.Reporter, error); errors when opts.Logger.GetSink() == nil (zero-value / not provided) - Add Logger logr.Logger field to yamlreport.Opts and reporter struct - Replace zerologr.Info() global call in internal/otel with logr.FromContextOrDiscard(ctx).Info() (context transport) - Update yaml_test.go to supply an explicit logger via funcr Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Logger is passed by value, not a pointer, so a zero-value logger is always 'provided' — validating the sink is not meaningful. Revert New() to returning report.Reporter directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
maansaake
force-pushed
the
refactor/remove-package-level-loggers
branch
from
May 24, 2026 03:12
4d43917 to
ac1d833
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes all package-level logger variables from the
arbiterrepository and replaces them with explicit logger passing.Changes
Delete
internal/log— theabtrlogpackage (global logger +GetLogger()) is removed entirely. Its setup logic is inlined into a newsetupLoggers()helper inarbiter.go.arbiter.govar logger logr.Loggerremovedlogger logr.Loggeradded as a field on theabtrstruct, populated inRun()startModules()converted from a package-level function to a method onabtrsetupReporter()updated to return(report.Reporter, error)and passesa.loggerto the yaml reporterdefaultOpts()was settingInfoLogPathtwice and never settingErrorLogPathpkg/report/yaml/yaml.govar logger logr.LoggerremovedLogger logr.Loggeradded toOptsand the internalreporterstructNew()now returns(report.Reporter, error)and returns an error whenopts.Logger.GetSink() == nil(logger not provided)internal/otel/instrument.gozerologr.Info()(implicit global) replaced withlogr.FromContextOrDiscard(ctx).Info()— the function already carriedctx context.ContextNotes
In logr v1.4.3,
logr.Discard()returns a nil-sink Logger (same as the zero value), so the zero-value guard works correctly. Test code should usefuncr.New(...)ortestr.New(t)instead oflogr.Discard().