-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Expand Blazor logging #11919
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
Merged
Merged
Expand Blazor logging #11919
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b4f4785
Log when rendering component
SteveSandersonMS aaa2784
Log component initialization
SteveSandersonMS d277250
Log component disposal
SteveSandersonMS e009ef5
Use LogLevel.Debug
SteveSandersonMS ee114c4
Improve logging of sending render batches
SteveSandersonMS 79905ae
PascalCase some things
SteveSandersonMS f5e531b
Log creating circuits
SteveSandersonMS 95f41eb
Inline const, as it will be confusing otherwise
SteveSandersonMS 3a52d7d
Log event notifications
SteveSandersonMS cf83157
Log navigation
SteveSandersonMS 3be6f45
CR: Populate _logger in the correct place
SteveSandersonMS d5f46a7
Don't throw for missing event args
SteveSandersonMS 2bfb671
Make ILoggerFactory a constructor parameter for Renderer
SteveSandersonMS 2d0dc36
CR: Use LogLevel.Debug
SteveSandersonMS e9e0745
CR: Use LoggerMessage for batch completion messages
SteveSandersonMS 4687b19
CR: Convert log calls in RemoteUriHelper to use LoggerMessage
SteveSandersonMS ba42c14
CR: Convert log calls in ComponentHub to use LoggerMessage
SteveSandersonMS 0280aef
Use LogLevel.Debug in more places
SteveSandersonMS 180e68d
Fix build
SteveSandersonMS 68ef5d2
Test fix
SteveSandersonMS 257e1fc
Ref assembly updates
SteveSandersonMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.AspNetCore.Components.Rendering | ||
{ | ||
public abstract partial class Renderer | ||
{ | ||
internal static class Log | ||
{ | ||
private static readonly Action<ILogger, int, Type, int, Type, Exception> _initializingChildComponent = | ||
LoggerMessage.Define<int, Type, int, Type>(LogLevel.Debug, new EventId(1, "InitializingChildComponent"), "Initializing component {ComponentId} ({ComponentType}) as child of {ParentComponentId} ({ParentComponentId})"); | ||
|
||
private static readonly Action<ILogger, int, Type, Exception> _initializingRootComponent = | ||
LoggerMessage.Define<int, Type>(LogLevel.Debug, new EventId(2, "InitializingRootComponent"), "Initializing root component {ComponentId} ({ComponentType})"); | ||
|
||
private static readonly Action<ILogger, int, Type, Exception> _renderingComponent = | ||
LoggerMessage.Define<int, Type>(LogLevel.Debug, new EventId(3, "RenderingComponent"), "Rendering component {ComponentId} of type {ComponentType}"); | ||
|
||
private static readonly Action<ILogger, int, Type, Exception> _disposingComponent = | ||
LoggerMessage.Define<int, Type>(LogLevel.Debug, new EventId(4, "DisposingComponent"), "Disposing component {ComponentId} of type {ComponentType}"); | ||
|
||
private static readonly Action<ILogger, int, string, Exception> _handlingEvent = | ||
LoggerMessage.Define<int, string>(LogLevel.Debug, new EventId(5, "HandlingEvent"), "Handling event {EventId} of type '{EventType}'"); | ||
|
||
public static void InitializingComponent(ILogger logger, ComponentState componentState, ComponentState parentComponentState) | ||
{ | ||
if (logger.IsEnabled(LogLevel.Debug)) // This is almost always false, so skip the evaluations | ||
{ | ||
if (parentComponentState == null) | ||
{ | ||
_initializingRootComponent(logger, componentState.ComponentId, componentState.Component.GetType(), null); | ||
} | ||
else | ||
{ | ||
_initializingChildComponent(logger, componentState.ComponentId, componentState.Component.GetType(), parentComponentState.ComponentId, parentComponentState.Component.GetType(), null); | ||
} | ||
} | ||
} | ||
|
||
public static void RenderingComponent(ILogger logger, ComponentState componentState) | ||
{ | ||
if (logger.IsEnabled(LogLevel.Debug)) // This is almost always false, so skip the evaluations | ||
{ | ||
_renderingComponent(logger, componentState.ComponentId, componentState.Component.GetType(), null); | ||
} | ||
} | ||
|
||
internal static void DisposingComponent(ILogger<Renderer> logger, ComponentState componentState) | ||
{ | ||
if (logger.IsEnabled(LogLevel.Debug)) // This is almost always false, so skip the evaluations | ||
{ | ||
_disposingComponent(logger, componentState.ComponentId, componentState.Component.GetType(), null); | ||
} | ||
} | ||
|
||
internal static void HandlingEvent(ILogger<Renderer> logger, int eventHandlerId, UIEventArgs eventArgs) | ||
{ | ||
_handlingEvent(logger, eventHandlerId, eventArgs?.Type ?? "null", null); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.