lib/logrusr: consolidate logrus utilities#13034
Open
Brian-McM wants to merge 1 commit into
Open
Conversation
7197a09 to
9006c9d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates generic Logrus utilities by moving them from libcalico-go/lib/logutils into the standalone adapter module lib/logrusr, while leaving component-specific logging orchestration in place (e.g., felix/logutils, typha/pkg/logutils, confd/pkg/log). It updates a wide set of callers and regenerates local dependency manifests accordingly.
Changes:
- Migrate formatter/background destinations/hooks, rate-limited logger, redaction/sensitive helpers, and testing redirection helpers into
lib/logrusr. - Update call sites across many components to import and use
github.com/projectcalico/calico/lib/logrusrinstead oflibcalico-go/lib/logutils(and remove the oldlogformatsubpackage usage). - Regenerate
deps.txtfiles to reflect the new local module dependencies (lib/logrusr,lib/std/log).
Reviewed changes
Copilot reviewed 93 out of 94 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| whisker-backend/pkg/config/api.go | Switch logging formatter configuration import to lib/logrusr. |
| webhooks/pkg/webhook/command.go | Switch logging formatter configuration import to lib/logrusr. |
| typha/pkg/syncproto/sync_proto.go | Use logrusr.NewRateLimitedLogger() for rate-limited logging. |
| typha/pkg/logutils/logutils.go | Update Typha logging orchestration to use logrusr primitives. |
| typha/pkg/logutils/logutils_other.go | Update non-Linux stubs to use logrusr types. |
| typha/pkg/logutils/logutils_linux.go | Update Linux destinations to use logrusr constructors/types. |
| typha/pkg/config/env_var_loader.go | Use logrusr.IsSensitiveParam for env var redaction. |
| typha/fv-tests/reconnection_test.go | Redirect Logrus output using logrusr testing helper. |
| typha/deps.txt | Regenerated to depend on local:lib/logrusr and local:lib/std/log. |
| test-tools/mocknode/cmd/mocknode/main.go | Switch to logrusr (formatter, null writer, background hook, flush field). |
| test-tools/deps.txt | Regenerated to depend on local:lib/logrusr and local:lib/std/log. |
| release/deps.txt | Regenerated to depend on local:lib/logrusr and local:lib/std/log. |
| release/cmd/main.go | Switch logging formatter configuration import to lib/logrusr. |
| pod2daemon/pkg/csi/run.go | Switch logging formatter configuration import to lib/logrusr. |
| node/pkg/node/command.go | Switch per-command formatter setup to logrusr.Formatter / ConfigureFormatter. |
| node/deps.txt | Regenerated to depend on local:lib/logrusr and local:lib/std/log. |
| libcalico-go/lib/testutils/ginkgolog.go | Update Ginkgo Logrus hookup to call logrusr.ConfigureFormatter. |
| libcalico-go/lib/backend/syncersv1/dedupebuffer/dedupe_buffer_test.go | Update test logging formatter setup to logrusr. |
| lib/logrusr/suite_test.go | Rename suite/package and inline Logrus-to-Ginkgo wiring without libcalico-go testutils dependency. |
| lib/logrusr/sensitive.go | Package rename to logrusr for sensitive/redaction helpers. |
| lib/logrusr/ratelimited.go | Package rename to logrusr for rate-limited logger implementation. |
| lib/logrusr/ratelimited_test.go | Update tests to logrusr package naming/imports. |
| lib/logrusr/go.sum | Updated module sums after consolidation and test deps. |
| lib/logrusr/go.mod | Add required deps (incl. Prometheus and Ginkgo/Gomega for tests). |
| lib/logrusr/formatter.go | Collapse former logformat code into logrusr package. |
| lib/logrusr/destination.go | Collapse former destination/background hook code into logrusr package and use local formatter helpers. |
| lib/logrusr/destination_test.go | Update tests to new package and file name expectations. |
| lib/logrusr/benchmarks_test.go | Update benchmark package name to logrusr. |
| lib/logrusr/another_file_for_test.go | Update test package name to logrusr_test. |
| kube-controllers/pkg/kubecontrollers/run.go | Switch logging formatter configuration import to lib/logrusr. |
| kube-controllers/pkg/controllers/tier/tier_controller_fv_test.go | Switch formatter type usage to logrusr.Formatter. |
| kube-controllers/pkg/controllers/serviceaccount/serviceaccount_controller_fv_test.go | Switch formatter type usage to logrusr.Formatter. |
| kube-controllers/pkg/controllers/namespace/namespace_controller_fv_test.go | Switch formatter type usage to logrusr.Formatter. |
| kube-controllers/pkg/controllers/migration/controller_fv_test.go | Switch formatter type usage to logrusr.Formatter. |
| kube-controllers/deps.txt | Regenerated to include local:lib/logrusr and local:lib/std/log. |
| hack/deps.txt | Regenerated to include local:lib/logrusr and local:lib/std/log. |
| hack/cmd/deps/deps.go | Switch logging formatter configuration import to lib/logrusr. |
| hack/cmd/coalesce-imports/coalesce-imports.go | Replace logformat.ConfigureFormatter usage with logrusr.ConfigureFormatter. |
| guardian/tests/fv/fv_test.go | Switch formatter + testing redirection to logrusr. |
| guardian/pkg/tunnel/suite_test.go | Switch formatter + testing redirection to logrusr. |
| guardian/pkg/conn/forward_test.go | Switch formatter + testing redirection to logrusr. |
| guardian/pkg/config/config.go | Switch logging formatter configuration import to lib/logrusr. |
| guardian/cmd/guardian/command.go | Use logrusr.RedactURL for logging sanitized config. |
| goldmane/pkg/stream/stream.go | Switch RateLimitedLogger type to logrusr. |
| goldmane/pkg/stream/stream_manager.go | Switch rate-limited logger construction to logrusr opts. |
| goldmane/pkg/storage/index_test.go | Switch Logrus-to-testing redirection to logrusr. |
| goldmane/pkg/storage/diachronic_flow_test.go | Switch Logrus-to-testing redirection to logrusr. |
| goldmane/pkg/internal/utils/logging.go | Switch logging formatter configuration import to lib/logrusr. |
| goldmane/pkg/internal/utils/files_test.go | Switch Logrus-to-testing redirection to logrusr. |
| goldmane/pkg/goldmane/goldmane.go | Switch RateLimitedLogger type to logrusr. |
| goldmane/pkg/goldmane/goldmane_test.go | Switch Logrus-to-testing redirection to logrusr. |
| goldmane/pkg/emitter/emitter.go | Use logrusr.RedactURL for sanitized URL logging. |
| goldmane/pkg/emitter/emitter_test.go | Switch Logrus-to-testing redirection to logrusr. |
| goldmane/pkg/daemon/daemon.go | Use logrusr.RedactURL for sanitized config logging. |
| goldmane/fv/flow_collector_test.go | Switch Logrus-to-testing redirection to logrusr. |
| goldmane/fv/daemon_test.go | Switch formatter + Logrus-to-testing redirection to logrusr. |
| goldmane/deps.txt | Regenerated to include local:lib/logrusr and local:lib/std/log. |
| felix/wireguard/wireguard.go | Switch rate-limited logger to logrusr. |
| felix/vxlanfdb/vxlan_fdb_test.go | Switch formatter/testing logging helpers to logrusr. |
| felix/nftables/table.go | Switch imported rate-limited logger types/opts alias to lib/logrusr. |
| felix/nfnetlink/nflog_linux.go | Switch rate-limited logger to logrusr. |
| felix/logutils/logutils.go | Update Felix logging orchestration to use logrusr primitives. |
| felix/logutils/logutils_windows.go | Update Windows destinations to use logrusr constructors/types. |
| felix/logutils/logutils_linux.go | Update Linux destinations to use logrusr constructors/types. |
| felix/linkaddrs/link_addrs_test.go | Switch formatter/testing logging helpers to logrusr. |
| felix/labelindex/named_port_index_test.go | Switch testing logging helper to logrusr. |
| felix/iptables/table.go | Switch imported rate-limited logger types/opts alias to lib/logrusr. |
| felix/fv/test-workload/test-workload.go | Switch logging formatter configuration import to lib/logrusr. |
| felix/deps.txt | Regenerated to include local:lib/logrusr and local:lib/std/log. |
| felix/dataplane/linux/int_dataplane.go | Switch flush field constant reference to logrusr.FieldForceFlush. |
| felix/dataplane/linux/bpf_ep_mgr.go | Switch imported rate-limited logger types/opts alias to lib/logrusr. |
| felix/dataplane/external/ext_dataplane_test.go | Switch testing logging helpers to logrusr. |
| felix/daemon/daemon.go | Switch flush field constant reference to logrusr.FieldForceFlush. |
| felix/config/env_var_loader.go | Use logrusr.IsSensitiveParam for env var redaction. |
| felix/collector/types/tuple/tuple_suite_test.go | Switch formatter configuration import to lib/logrusr. |
| felix/collector/types/counter/counter_suite_test.go | Switch formatter configuration import to lib/logrusr. |
| felix/collector/flowlog/types.go | Switch rate-limited logger to logrusr. |
| felix/collector/flowlog/flowlogs_suite_test.go | Switch formatter configuration import to lib/logrusr. |
| felix/cmd/calico-felix-docgen/calico-felix-docgen.go | Switch logging formatter configuration import to lib/logrusr. |
| confd/pkg/log/log.go | Switch logging formatter configuration import to lib/logrusr. |
| confd/deps.txt | Regenerated to include local:lib/logrusr and local:lib/std/log. |
| cni-plugin/pkg/plugin/plugin.go | Switch logging formatter configuration import to lib/logrusr. |
| cni-plugin/pkg/ipamplugin/ipam_plugin.go | Switch logging formatter configuration import to lib/logrusr. |
| cni-plugin/pkg/install/install.go | Switch logging formatter configuration import to lib/logrusr. |
| cni-plugin/deps.txt | Regenerated to include local:lib/logrusr and local:lib/std/log. |
| cmd/deps.txt | Regenerated to remove old libcalico-go/lib/logutils references. |
| calicoctl/tests/fv/namespace_option_test.go | Switch formatter configuration import to lib/logrusr. |
| calicoctl/tests/fv/multi_context_test.go | Switch formatter configuration import to lib/logrusr. |
| calicoctl/tests/fv/migrate_ipam_test.go | Switch formatter configuration import to lib/logrusr. |
| calicoctl/tests/fv/ipam_test.go | Switch formatter configuration import to lib/logrusr. |
| calicoctl/calicoctl/commands/cluster/diags_test.go | Switch formatter configuration import to lib/logrusr. |
| app-policy/checker/check.go | Switch rate-limited logger to logrusr. |
| apiserver/cmd/apiserver/server/logging.go | Switch to logrusr.SafeParseLogLevel. |
Comments suppressed due to low confidence (1)
lib/logrusr/formatter.go:19
- The package-level doc comment still refers to
logformatand to a parentlogutilspackage, but the package is nowlogrusr. This can confuse GoDoc readers (and some linters expect the comment to start with the actual package name).
Contributor
CI triage — CalicoRecommendation: Dig deeper before merging Likely caused by this PR
workflow_id: 7e4a4171-2ebe-4b8a-b85f-3f220deb1dc0 |
9006c9d to
d138b0e
Compare
Move the logrus-specific utility code that used to live in
libcalico-go/lib/logutils into lib/logrusr. The migrated APIs include:
- Formatter / ConfigureFormatter and the legacy Calico log line shape.
- Background-dispatch destinations (stream, syslog) with optional log
dropping and Prometheus counters.
- RateLimitedLogger and its options.
- BackgroundHook with optional debug-file regexp filtering.
- SafeParseLogLevel, IsSensitiveParam, RedactURL.
- testing.TB hookup helpers (RedirectLogrusToTestingT/TB,
ConfigureLoggingForTestingT/TB).
- Summarizer / OpRecorder (moved from felix/logutils — generic
logrus-shaped utility used by Felix dataplane managers).
The old logformat sub-package collapses into lib/logrusr; the only
external caller (hack/cmd/coalesce-imports) is updated to use
logrusr directly.
Delete the component-specific logutils packages now that the generic
primitives live in lib/logrusr:
- felix/logutils → felix/logging. Same Felix-specific Configure /
Tracef / Dump / RegisterProfilingSignalHandlers helpers, just under
a name that reflects what's left after the generic bits moved out.
- typha/pkg/logutils → typha/pkg/logging.
- confd/pkg/log → deleted. SetLevel inlines into confd/pkg/config (the
only caller location); ConfigureFormatter("confd") moves to
confd.go's main.
All 70+ callers across apiserver, app-policy, calicoctl, cni-plugin,
confd, felix, goldmane, guardian, hack, kube-controllers, libcalico-go,
node, pod2daemon, release, test-tools, typha, webhooks, and
whisker-backend are updated. libcalico-go/lib/logutils is deleted.
cmd/deps.txt and .semaphore/semaphore.yml are regenerated.
d138b0e to
fbb595a
Compare
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
Move all generic logrus utility code out of
libcalico-go/lib/logutilsand intolib/logrusr(the adapter module added in #12968). Component-specific orchestration (felix/logutils,typha/pkg/logutils,confd/pkg/log) stays where it lives — only the primitives consolidate.Moved to lib/logrusr:
Formatter/ConfigureFormatterand the Calico log line shape (timestamp, level, PID, component/file:line, message, sorted KVs).NewStreamDestination,NewSyslogDestination) with optional log dropping and Prometheus counters.BackgroundHookandWithDebugFileRegexp.RateLimitedLogger,NewRateLimitedLogger,OptInterval,OptBurst,OptLogger.SafeParseLogLevel,IsSensitiveParam,RedactURL.RedirectLogrusToTestingT/TB,ConfigureLoggingForTestingT/TB).The old
logformatsub-package collapses intolib/logrusr— its only external caller (hack/cmd/coalesce-imports) is updated.Caller updates: 70+ files across apiserver, app-policy, calicoctl, cni-plugin, confd, felix, goldmane, guardian, hack, kube-controllers, libcalico-go, node, pod2daemon, release, test-tools, typha, webhooks, and whisker-backend.
libcalico-go/lib/logutilsis deleted.cmd/deps.txtand per-componentdeps.txtfiles are regenerated.Test plan
🤖 Generated with Claude Code