Skip to content

Use logger factory instead of console for codeowners library logging#12022

Merged
benbp merged 1 commit into
Azure:mainfrom
benbp:benbp/codeowners-console
Sep 10, 2025
Merged

Use logger factory instead of console for codeowners library logging#12022
benbp merged 1 commit into
Azure:mainfrom
benbp:benbp/codeowners-console

Conversation

@benbp
Copy link
Copy Markdown
Member

@benbp benbp commented Sep 9, 2025

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.WriteLine so this refactors it to follow the guidance at https://learn.microsoft.com/en-us/dotnet/core/extensions/logging-library-authors

@benbp benbp added the Central-EngSys This issue is owned by the Engineering System team. label Sep 9, 2025
@benbp benbp self-assigned this Sep 9, 2025
@benbp benbp requested review from Copilot and weshaggard September 9, 2025 22:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread tools/codeowners-utils/Azure.Sdk.Tools.CodeownersUtils/Utils/Log.cs
@benbp benbp force-pushed the benbp/codeowners-console branch from a3adae9 to 648ad6c Compare September 9, 2025 22:16
@benbp benbp merged commit c4a4a48 into Azure:main Sep 10, 2025
43 checks passed
@github-project-automation github-project-automation Bot moved this from 🤔 Triage to 🔬 Dev in PR in Azure SDK EngSys 🚀🌒🧑‍🚀 Sep 10, 2025
@benbp benbp added the azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli label Sep 10, 2025
@benbp benbp deleted the benbp/codeowners-console branch September 10, 2025 18:06
benbp added a commit to benbp/azure-sdk-tools that referenced this pull request Sep 10, 2025
@kurtzeborn kurtzeborn moved this from 🔬 Dev in PR to 🎊 Closed in Azure SDK EngSys 🚀🌒🧑‍🚀 Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli Central-EngSys This issue is owned by the Engineering System team.

Projects

Development

Successfully merging this pull request may close these issues.

4 participants