Use logger factory instead of console for codeowners library logging#12022
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR replaces console logging with structured logging using Microsoft.Extensions.Logging throughout the codeowners utilities library. The change introduces a static Log helper class that allows consumers to configure logging while defaulting to a NullLogger to maintain backward compatibility.
- Introduces a new Log helper class with configurable ILogger support
- Replaces all Console.WriteLine calls with structured logging calls using Log.Logger
- Updates project files to include necessary logging dependencies
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/codeowners-utils/Azure.Sdk.Tools.CodeownersUtils/Utils/Log.cs | New static logging helper class with configurable ILogger support |
| tools/codeowners-utils/Azure.Sdk.Tools.CodeownersUtils/Utils/FileHelpers.cs | Replaced console logging with structured logging in HTTP retry logic |
| tools/codeowners-utils/Azure.Sdk.Tools.CodeownersUtils/Caches/TeamUserCache.cs | Replaced console logging with structured logging for error and warning messages |
| tools/codeowners-utils/Azure.Sdk.Tools.CodeownersUtils/Azure.Sdk.Tools.CodeownersUtils.csproj | Added Microsoft.Extensions.Logging.Abstractions package reference |
| tools/codeowners-utils/Azure.Sdk.Tools.CodeownersLinter/Program.cs | Configured logger factory and replaced all console output with structured logging |
| tools/codeowners-utils/Azure.Sdk.Tools.CodeownersLinter/Azure.Sdk.Tools.CodeownersLinter.csproj | Added Microsoft.Extensions.Logging.Console package reference |
| tools/codeowners-utils/Azure.Sdk.Tools.CodeownersLinter.Tests/Utils/BaselineUtilsTests.cs | Replaced console logging in test cleanup with structured logging |
| tools/codeowners-utils/Azure.Sdk.Tools.CodeownersLinter.Tests/TestHelpers.cs | Replaced console logging in test helpers with structured logging |
| tools/azsdk-cli/Azure.Sdk.Tools.Cli/Tools/EngSys/CodeownersTools/CodeownersTools.cs | Updated constructor to accept and configure logger factory for the library |
| tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Tools/CodeownersToolsTests.cs | Updated test constructor calls to pass null for the new logger factory parameter |
weshaggard
approved these changes
Sep 9, 2025
a3adae9 to
648ad6c
Compare
benbp
added a commit
to benbp/azure-sdk-tools
that referenced
this pull request
Sep 10, 2025
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.
The codeowners tests were adding a bunch of logging that was coming out of the codeowners utils library, which was annoying me. As a library it should not be using
Console.WriteLineso this refactors it to follow the guidance at https://learn.microsoft.com/en-us/dotnet/core/extensions/logging-library-authors