Disable logging for wasm release, share logging for Uno

This commit is contained in:
Jérôme Laban 2019-05-24 20:30:46 -04:00
commit 6ec5d20fb2
4 changed files with 61 additions and 44 deletions

View file

@ -34,6 +34,10 @@ namespace CalculatorApp
/// </summary> /// </summary>
public App() public App()
{ {
#if HAS_UNO
ConfigureFilters(Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory);
#endif
this.InitializeComponent(); this.InitializeComponent();
this.Suspending += OnSuspending; this.Suspending += OnSuspending;
} }
@ -91,10 +95,52 @@ namespace CalculatorApp
} }
} }
/// <summary> #if HAS_UNO
/// Return True if animation is enabled by user setting. static void ConfigureFilters(Microsoft.Extensions.Logging.ILoggerFactory factory)
/// </summary> {
public static bool IsAnimationEnabled() #if DEBUG
factory
.WithFilter(new Microsoft.Extensions.Logging.FilterLoggerSettings
{
{ "Uno", LogLevel.Warning },
{ "Windows", LogLevel.Warning },
// Generic Xaml events
//{ "Windows.UI.Xaml", LogLevel.Debug },
// { "Windows.UI.Xaml.Shapes", LogLevel.Debug },
//{ "Windows.UI.Xaml.VisualStateGroup", LogLevel.Debug },
//{ "Windows.UI.Xaml.StateTriggerBase", LogLevel.Debug },
// { "Windows.UI.Xaml.UIElement", LogLevel.Debug },
// { "Windows.UI.Xaml.Setter", LogLevel.Debug },
// Layouter specific messages
// { "Windows.UI.Xaml.Controls", LogLevel.Debug },
//{ "Windows.UI.Xaml.Controls.Layouter", LogLevel.Debug },
//{ "Windows.UI.Xaml.Controls.Panel", LogLevel.Debug },
// Binding related messages
// { "Windows.UI.Xaml.Data", LogLevel.Debug },
// { "Windows.UI.Xamll.Data", LogLevel.Debug },
// Binder memory references tracking
// { "ReferenceHolder", LogLevel.Debug },
}
)
.AddConsole(LogLevel.Trace);
#else
#if !__WASM__
factory
.AddConsole(LogLevel.Error);
#endifs
#endif
}
#endif
/// <summary>
/// Return True if animation is enabled by user setting.
/// </summary>
public static bool IsAnimationEnabled()
{ {
return m_isAnimationEnabled; return m_isAnimationEnabled;
} }

View file

@ -33,6 +33,13 @@
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Content Include="LinkerConfig.xml" /> <Content Include="LinkerConfig.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<WasmShellMonoEnvironment Include="MONO_GC_PARAMS" Value="soft-heap-limit=512m,nursery-size=64m,evacuation-threshold=66,major=marksweep" />
<WasmShellMonoEnvironment Include="MONO_LOG_LEVEL" Value="debug" />
<WasmShellMonoEnvironment Include="MONO_LOG_MASK" Value="gc" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />

View file

@ -14,45 +14,7 @@ namespace WindowsCalculator.Wasm
{ {
Console.WriteLine("Program.Main"); Console.WriteLine("Program.Main");
ConfigureFilters(LogExtensionPoint.AmbientLoggerFactory);
Windows.UI.Xaml.Application.Start(_ => _app = new App()); Windows.UI.Xaml.Application.Start(_ => _app = new App());
} }
static void ConfigureFilters(ILoggerFactory factory)
{
#if DEBUG
factory
.WithFilter(new FilterLoggerSettings
{
{ "Uno", LogLevel.Warning },
{ "Windows", LogLevel.Warning },
// Generic Xaml events
//{ "Windows.UI.Xaml", LogLevel.Debug },
// { "Windows.UI.Xaml.Shapes", LogLevel.Debug },
//{ "Windows.UI.Xaml.VisualStateGroup", LogLevel.Debug },
//{ "Windows.UI.Xaml.StateTriggerBase", LogLevel.Debug },
// { "Windows.UI.Xaml.UIElement", LogLevel.Debug },
// { "Windows.UI.Xaml.Setter", LogLevel.Debug },
// Layouter specific messages
// { "Windows.UI.Xaml.Controls", LogLevel.Debug },
//{ "Windows.UI.Xaml.Controls.Layouter", LogLevel.Debug },
//{ "Windows.UI.Xaml.Controls.Panel", LogLevel.Debug },
// Binding related messages
// { "Windows.UI.Xaml.Data", LogLevel.Debug },
// { "Windows.UI.Xamll.Data", LogLevel.Debug },
// Binder memory references tracking
// { "ReferenceHolder", LogLevel.Debug },
}
)
.AddConsole(LogLevel.Trace);
#else
factory
.AddConsole(LogLevel.Error);
#endif
}
} }
} }

View file

@ -191,7 +191,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Uno.UI" Version="1.45.0-dev.1550" /> <PackageReference Include="Uno.UI" Version="1.45.0-dev.1550" />
</ItemGroup> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'iPhoneSimulator' "> <ItemGroup Condition=" '$(Platform)' == 'iPhoneSimulator' ">
<NativeReference Include="NativeReferences/x86_64/libCalcManager.a"> <NativeReference Include="NativeReferences/x86_64/libCalcManager.a">
<Kind>Static</Kind> <Kind>Static</Kind>
@ -204,4 +206,4 @@
</ItemGroup> </ItemGroup>
<Import Project="..\Calculator.Shared\Calculator.Shared.projitems" Label="Shared" Condition="Exists('..\Calculator.Shared\Calculator.Shared.projitems')" /> <Import Project="..\Calculator.Shared\Calculator.Shared.projitems" Label="Shared" Condition="Exists('..\Calculator.Shared\Calculator.Shared.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project> </Project>