Skip to content

Commit

Permalink
Merge pull request #2670 from unoplatform/dev/jela/browser-log
Browse files Browse the repository at this point in the history
fix: Use browser logger on Wasm browser
  • Loading branch information
jeromelaban authored Jan 14, 2025
2 parents 092acdc + 807bc7f commit b16e160
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/Uno.Extensions.Logging/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,24 @@ public static IHostBuilder UseLogging(
{
if (!context.IsRegistered(nameof(UseLogging)))
{
#if !__WASM__
#if __IOS__
#pragma warning disable CA1416 // Validate platform compatibility: The net8.0 version is not used on older versions of OS
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
#pragma warning restore CA1416 // Validate platform compatibility
#elif NET6_0_OR_GREATER || __SKIA__ // Console isn't supported on all Xamarin targets, so only adding for net8.0 and above
builder.AddConsole();

if (OperatingSystem.IsBrowser())
{
#if !__IOS__ && !__ANDROID__ && !__SKIA__ && !__WINDOWS__ && !DESKTOP1_0_OR_GREATER
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
#endif
builder.AddDebug();
#elif __WASM__
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
}
else
{
builder.AddConsole();
}
#endif
builder.AddDebug();
}

configure?.Invoke(context, builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<ProjectReference Include="..\Uno.Extensions.Hosting\Uno.Extensions.Hosting.csproj" />
</ItemGroup>

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

0 comments on commit b16e160

Please sign in to comment.