Convert to source generation for logging#356
Conversation
c36b51e to
d242e34
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR converts the codebase from traditional logging calls to source generation for improved performance and better typing. It also removes color formatting from branch and stack names in logging messages to reduce visual distraction, while preserving colors for direct console output.
Key changes:
- Replace
Logger.LogXxx()calls with source-generated logging methods - Add
[LoggerMessage]attributes for compile-time logging optimization - Remove
.Branch(),.Stack(), and.Example()extension methods from logging messages
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| OutputStyleExtensionMethods.cs | Removes unused Example() extension method |
| LoggerExtensionMethods.cs | Adds source-generated logging methods for common operations |
| Command.cs | Converts error logging to source generation and adds internal logger extensions |
| ProcessHelpers.cs | Converts trace logging to source generation |
| GitClient.cs | Converts debug logging to source generation |
| Multiple command files | Replace traditional logging with source-generated methods and remove color formatting |
| [LoggerMessage(Level = LogLevel.Information, Message = "Rebasing stack {Stack} for branch line: {SourceBranch} --> {BranchLine}")] | ||
| public static partial void RebasingStackForBranchLine(this ILogger logger, string stack, string sourceBranch, string branchLine); | ||
|
|
||
| [LoggerMessage(Level = LogLevel.Debug, Message = "No active branches found for branch line.")] |
There was a problem hiding this comment.
The log level should be LogLevel.Warning to match the original code at line 257 which used logger.LogWarning.
| [LoggerMessage(Level = LogLevel.Debug, Message = "No active branches found for branch line.")] | |
| [LoggerMessage(Level = LogLevel.Warning, Message = "No active branches found for branch line.")] |
|
|
||
| internal static partial class LoggerExtensionMethods | ||
| { | ||
| [LoggerMessage(Level = LogLevel.Trace, Message = "Adding branch {Branch} to stack {Stack}.")] |
There was a problem hiding this comment.
The log level should be LogLevel.Information to match the original code at line 102 which used logger.LogInformation.
| [LoggerMessage(Level = LogLevel.Trace, Message = "Adding branch {Branch} to stack {Stack}.")] | |
| [LoggerMessage(Level = LogLevel.Information, Message = "Adding branch {Branch} to stack {Stack}.")] |
| [LoggerMessage(Level = LogLevel.Information, Message = "Branch {Branch} added to stack {Stack}.")] | ||
| public static partial void BranchAdded(this ILogger logger, string branch, string stack); |
There was a problem hiding this comment.
The original message at line 116 was just 'Branch added' without parameters. The message should be 'Branch added.' to match the original behavior.
d242e34 to
7a4d351
Compare
4f604f4 to
9a80cc1
Compare
Changes to use source generation for logging to improve performance and consistency of messages. Some slight changes to log levels of some messages which didn't seem right.