Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] Logging - comments for "magic numbers" #32455

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions aspnetcore/blazor/fundamentals/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ Blazor Web App:
Blazor.start({
circuit: {
configureSignalR: function (builder) {
builder.configureLogging(2);
builder.configureLogging(2); // LogLevel.Information
}
}
});
Expand All @@ -720,14 +720,17 @@ Blazor Server:
<script>
Blazor.start({
configureSignalR: function (builder) {
builder.configureLogging(2);
builder.configureLogging(2); // LogLevel.Information
}
});
</script>
```

In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. For the location of the script, see <xref:blazor/project-structure#location-of-the-blazor-script>.

> [!NOTE]
> Using an integer to specify the logging level in Example 2, often referred to as a *magic number* or *magic constant*, is considered a poor coding practice because the integer doesn't clearly identify the logging level when viewing the source code. If minimizing the bytes transferred to the browser is a priority, using an integer might be justified (consider removing the comment in such cases).

For more information on Blazor startup (`Blazor.start()`), see <xref:blazor/fundamentals/startup>.

## SignalR client logging with app configuration
Expand Down