Skip to content

Commit caadf29

Browse files
authored
Merge pull request #2671 from unoplatform/mergify/bp/release/stable/5.2/pr-2670
fix: Use browser logger on Wasm browser (backport #2670)
2 parents 00fde2b + 3464810 commit caadf29

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Uno.Extensions.Logging/HostBuilderExtensions.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,24 @@ public static IHostBuilder UseLogging(
5353
{
5454
if (!context.IsRegistered(nameof(UseLogging)))
5555
{
56-
#if !__WASM__
5756
#if __IOS__
5857
#pragma warning disable CA1416 // Validate platform compatibility: The net8.0 version is not used on older versions of OS
5958
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
6059
#pragma warning restore CA1416 // Validate platform compatibility
6160
#elif NET6_0_OR_GREATER || __SKIA__ // Console isn't supported on all Xamarin targets, so only adding for net8.0 and above
62-
builder.AddConsole();
61+
62+
if (OperatingSystem.IsBrowser())
63+
{
64+
#if !__IOS__ && !__ANDROID__ && !__SKIA__ && !__WINDOWS__ && !DESKTOP1_0_OR_GREATER
65+
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
6366
#endif
64-
builder.AddDebug();
65-
#elif __WASM__
66-
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
67+
}
68+
else
69+
{
70+
builder.AddConsole();
71+
}
6772
#endif
73+
builder.AddDebug();
6874
}
6975

7076
configure?.Invoke(context, builder);

src/Uno.Extensions.Logging/Uno.Extensions.Logging.WinUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<ProjectReference Include="..\Uno.Extensions.Hosting\Uno.Extensions.Hosting.csproj" />
3131
</ItemGroup>
3232

33-
<ItemGroup Condition="'$(IsBrowserWasm)'=='true'">
33+
<ItemGroup Condition="'$(IsBrowserWasm)'=='true' or '$(TargetFramework)' == 'net8.0'">
3434
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" />
3535
</ItemGroup>
3636
</Project>

0 commit comments

Comments
 (0)