-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ref): use explicit child/scoped loggers, avoid variable shadowing
I even know about variable shadowing, but here we are. In any case, while Go 1.22 should fix the loop variable shadowing issue, I find it much cleaner and clearer to use explicitly scoped, named loggers where possible. Fixes a few issues where log statements would continuously grow and add more keys on in each iteration of loops because I was reusing the same logger reference in each iteration. Ex (note the `module` field added on from all of the various module run loops): ``` Apr 08 04:10:52 testbox-arch mango[1744]: {"time":"2024-04-08T04:10:52.970064415Z","level":"DEBUG","msg":"No module variables","hostname":{"system":"testbox-arch","inventory":"testbox-arch"},"worker":"manager","manager":{"inventory":"/opt/mango/inventory","hostname":"testbox-arch"},"manager":{"enrolled":true,"runID":"01HTXYDQ54N7BNNFQSEC42NC9M"},"module":{"id":"/opt/mango/inventory/modules/test-requires-3"},"module":{"id":"/opt/mango/inventory/modules/test-requires-4"},"module":{"id":"/opt/mango/inventory/modules/test-requires-5"},"module":{"id":"/opt/mango/inventory/modules/test-reload"},"module":{"id":"/opt/mango/inventory/modules/test-env-vars"},"module":{"id":"/opt/mango/inventory/modules/test-template"},"module":{"id":"/opt/mango/inventory/modules/test-requires-1"},"module":{"id":"/opt/mango/inventory/modules/test-requires-2"}} ```
- Loading branch information
Showing
10 changed files
with
63 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.