-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(Orleans.Runtime): Use LoggerMessageGenerator for core logging messages #9316
base: main
Are you sure you want to change the base?
Conversation
src/Orleans.Runtime/Cancellation/CancellationSourcesExtension.cs
Outdated
Show resolved
Hide resolved
src/Orleans.Runtime/Cancellation/CancellationSourcesExtension.cs
Outdated
Show resolved
Hide resolved
src/Orleans.Runtime/Cancellation/CancellationSourcesExtension.cs
Outdated
Show resolved
Hide resolved
trying github copilot edits with the following prompt: Replace usages of ILogger methods with a log method annotated with [LoggerMessage] if there's a private field of type ILogger make the generated method If the log method is wrapped in an when a method call is passed to the log message, create a struct that receives the object and overrides the ToString to call the method that was previously passed to the log message. the struct should be a nested The generated methods should be at the end of the class, the generated struct should be right before the generated methods. Examples: Example 1: _shared.Logger.LogWarning( (int)ErrorCode.Dispatcher_ExtendedMessageProcessing, "Current request has been active for {CurrentRequestActiveTime} for grain {Grain}. Currently executing {BlockingRequest}. Trying to enqueue {Message}.", currentRequestActiveTime, ToDetailedString(), _blockingRequest, message); should be converted to a method LogWarningDispatcher_ExtendedMessageProcessing(_shared.Logger, currentRequestActiveTime, new(this), _blockingRequest, message) where the signature of the method would be [LoggerMessage(
EventId = (int)ErrorCode.Dispatcher_ExtendedMessageProcessing,
Level = LogLevel.Warning,
Message = "Current request has been active for {CurrentRequestActiveTime} for grain {Grain}. Currently executing {BlockingRequest}. Trying to enqueue {Message}."
)]
private static partial void LogWarningDispatcher_ExtendedMessageProcessing(ILogger logger, TimeSpan currentRequestActiveTime, ActivationDetailsLogValue grain, Message blockingRequest, Message message)
convert all of the remaining logger methods Example 2: if (logger.IsEnabled(LogLevel.Debug))
{
logger.LogDebug("DeactivateActivations: {Count} activations.", list.Count);
} should be converted to a method LogDebugDeactivateActivations(list.Count) where the signature of the method would be [LoggerMessage(
Level = LogLevel.Debug,
Message = "DeactivateActivations: {Count} activations."
)]
private partial void LogDebugDeactivateActivations(int count) |
Could this include some adjustments to messages and log levels to make it more useful to enable information logs on the server? There's a few that considering the content I think are best to be at Trace level. |
@alrz can you comment on the specific log messages? |
@ReubenBond ready for review now, there are a few remaining #if DEBUG
if (_gateway.logger.IsEnabled(LogLevel.Trace)) _gateway.logger.LogTrace(
#endif which I didn't modify (maybe in a follow up, and the class |
part of #9273
Microsoft Reviewers: Open in CodeFlow