From 6ec5d20fb28e35c8bc73536045b33706c824c532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= Date: Fri, 24 May 2019 20:30:46 -0400 Subject: [PATCH] Disable logging for wasm release, share logging for Uno --- src/Calculator.Shared/App.xaml.cs | 54 ++++++++++++++++++++-- src/Calculator.Wasm/Calculator.Wasm.csproj | 7 +++ src/Calculator.Wasm/Program.cs | 38 --------------- src/Calculator.iOS/Calculator.iOS.csproj | 6 ++- 4 files changed, 61 insertions(+), 44 deletions(-) diff --git a/src/Calculator.Shared/App.xaml.cs b/src/Calculator.Shared/App.xaml.cs index bf38c091..17dff6c9 100644 --- a/src/Calculator.Shared/App.xaml.cs +++ b/src/Calculator.Shared/App.xaml.cs @@ -34,6 +34,10 @@ namespace CalculatorApp /// public App() { +#if HAS_UNO + ConfigureFilters(Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory); +#endif + this.InitializeComponent(); this.Suspending += OnSuspending; } @@ -91,10 +95,52 @@ namespace CalculatorApp } } - /// - /// Return True if animation is enabled by user setting. - /// - public static bool IsAnimationEnabled() +#if HAS_UNO + static void ConfigureFilters(Microsoft.Extensions.Logging.ILoggerFactory factory) + { +#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 + + + /// + /// Return True if animation is enabled by user setting. + /// + public static bool IsAnimationEnabled() { return m_isAnimationEnabled; } diff --git a/src/Calculator.Wasm/Calculator.Wasm.csproj b/src/Calculator.Wasm/Calculator.Wasm.csproj index 77f13551..9a295d9f 100644 --- a/src/Calculator.Wasm/Calculator.Wasm.csproj +++ b/src/Calculator.Wasm/Calculator.Wasm.csproj @@ -33,6 +33,13 @@ + + + + + + + diff --git a/src/Calculator.Wasm/Program.cs b/src/Calculator.Wasm/Program.cs index 40b01b4c..f6e3e9b9 100644 --- a/src/Calculator.Wasm/Program.cs +++ b/src/Calculator.Wasm/Program.cs @@ -14,45 +14,7 @@ namespace WindowsCalculator.Wasm { Console.WriteLine("Program.Main"); - ConfigureFilters(LogExtensionPoint.AmbientLoggerFactory); - 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 - } } } diff --git a/src/Calculator.iOS/Calculator.iOS.csproj b/src/Calculator.iOS/Calculator.iOS.csproj index ce4e5ae5..9cbedb92 100644 --- a/src/Calculator.iOS/Calculator.iOS.csproj +++ b/src/Calculator.iOS/Calculator.iOS.csproj @@ -191,7 +191,9 @@ - + + + Static @@ -204,4 +206,4 @@ - \ No newline at end of file +