diff --git a/Avalonia.sln b/Avalonia.sln index e8d5034fb0..5bff2fa0a0 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -95,8 +95,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.UnitTests", "tests EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Benchmarks", "tests\Avalonia.Benchmarks\Avalonia.Benchmarks.csproj", "{410AC439-81A1-4EB5-B5E9-6A7FC6B77F4B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Logging.Serilog", "src\Avalonia.Logging.Serilog\Avalonia.Logging.Serilog.csproj", "{B61B66A3-B82D-4875-8001-89D3394FE0C9}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.DesignerSupport", "src\Avalonia.DesignerSupport\Avalonia.DesignerSupport.csproj", "{799A7BB5-3C2C-48B6-85A7-406A12C420DA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlCatalog", "samples\ControlCatalog\ControlCatalog.csproj", "{D0A739B9-3C68-4BA6-A328-41606954B6BD}" @@ -140,7 +138,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{F3AC8BC1 build\ReactiveUI.props = build\ReactiveUI.props build\Rx.props = build\Rx.props build\SampleApp.props = build\SampleApp.props - build\Serilog.props = build\Serilog.props build\SharpDX.props = build\SharpDX.props build\SkiaSharp.props = build\SkiaSharp.props build\System.Memory.props = build\System.Memory.props @@ -1027,30 +1024,6 @@ Global {410AC439-81A1-4EB5-B5E9-6A7FC6B77F4B}.Release|iPhone.Build.0 = Release|Any CPU {410AC439-81A1-4EB5-B5E9-6A7FC6B77F4B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {410AC439-81A1-4EB5-B5E9-6A7FC6B77F4B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.AppStore|Any CPU.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.AppStore|Any CPU.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.AppStore|iPhone.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.AppStore|iPhone.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Debug|iPhone.Build.0 = Debug|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Release|Any CPU.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Release|iPhone.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Release|iPhone.Build.0 = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {B61B66A3-B82D-4875-8001-89D3394FE0C9}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {799A7BB5-3C2C-48B6-85A7-406A12C420DA}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU {799A7BB5-3C2C-48B6-85A7-406A12C420DA}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU {799A7BB5-3C2C-48B6-85A7-406A12C420DA}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU diff --git a/build/CoreLibraries.props b/build/CoreLibraries.props index 2b54ee3f56..d17eec0135 100644 --- a/build/CoreLibraries.props +++ b/build/CoreLibraries.props @@ -7,7 +7,6 @@ - diff --git a/build/Serilog.props b/build/Serilog.props deleted file mode 100644 index a814cf998d..0000000000 --- a/build/Serilog.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build/readme.md b/build/readme.md index 387afb3425..e147556b1c 100644 --- a/build/readme.md +++ b/build/readme.md @@ -9,8 +9,6 @@ - - @@ -22,4 +20,4 @@ ```XML -``` \ No newline at end of file +``` diff --git a/samples/BindingDemo/App.xaml.cs b/samples/BindingDemo/App.xaml.cs index f2f44cd502..13875aeb21 100644 --- a/samples/BindingDemo/App.xaml.cs +++ b/samples/BindingDemo/App.xaml.cs @@ -1,10 +1,8 @@ using System; using Avalonia; using Avalonia.Controls; -using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; using Avalonia.ReactiveUI; -using Serilog; namespace BindingDemo { diff --git a/samples/BindingDemo/BindingDemo.csproj b/samples/BindingDemo/BindingDemo.csproj index ce33f42143..817023fd71 100644 --- a/samples/BindingDemo/BindingDemo.csproj +++ b/samples/BindingDemo/BindingDemo.csproj @@ -10,7 +10,6 @@ - diff --git a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj index 054de2a05f..1a112d0d7d 100644 --- a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj +++ b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj @@ -10,6 +10,5 @@ - diff --git a/samples/ControlCatalog.Desktop/Program.cs b/samples/ControlCatalog.Desktop/Program.cs index 2a8d288614..b2df1953f5 100644 --- a/samples/ControlCatalog.Desktop/Program.cs +++ b/samples/ControlCatalog.Desktop/Program.cs @@ -2,10 +2,8 @@ using System; using System.Linq; using Avalonia; using Avalonia.Controls; -using Avalonia.Logging.Serilog; using Avalonia.Platform; using Avalonia.ReactiveUI; -using Serilog; namespace ControlCatalog { diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs index 2a5294cacc..5df8c1be64 100644 --- a/samples/ControlCatalog.NetCore/Program.cs +++ b/samples/ControlCatalog.NetCore/Program.cs @@ -1,13 +1,11 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Threading; using Avalonia; -using Avalonia.ReactiveUI; using Avalonia.Dialogs; -using Avalonia.OpenGL; +using Avalonia.ReactiveUI; namespace ControlCatalog.NetCore { @@ -69,7 +67,8 @@ namespace ControlCatalog.NetCore }) .UseSkia() .UseReactiveUI() - .UseManagedSystemDialogs(); + .UseManagedSystemDialogs() + .LogToDebug(); static void SilenceConsole() { diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index 34a6e33677..8a88b89b48 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -28,6 +28,5 @@ - diff --git a/samples/RenderDemo/App.xaml.cs b/samples/RenderDemo/App.xaml.cs index 923174d4c7..233160b025 100644 --- a/samples/RenderDemo/App.xaml.cs +++ b/samples/RenderDemo/App.xaml.cs @@ -1,5 +1,4 @@ using Avalonia; -using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; using Avalonia.ReactiveUI; @@ -22,6 +21,5 @@ namespace RenderDemo .UsePlatformDetect() .UseReactiveUI() .LogToDebug(); - } } diff --git a/samples/RenderDemo/RenderDemo.csproj b/samples/RenderDemo/RenderDemo.csproj index 0d7d62e177..d1654f4b54 100644 --- a/samples/RenderDemo/RenderDemo.csproj +++ b/samples/RenderDemo/RenderDemo.csproj @@ -13,7 +13,6 @@ - diff --git a/samples/VirtualizationDemo/Program.cs b/samples/VirtualizationDemo/Program.cs index 868a5e2640..93ea5e1b88 100644 --- a/samples/VirtualizationDemo/Program.cs +++ b/samples/VirtualizationDemo/Program.cs @@ -1,9 +1,7 @@ using System; using Avalonia; using Avalonia.Controls; -using Avalonia.Logging.Serilog; using Avalonia.ReactiveUI; -using Serilog; namespace VirtualizationDemo { diff --git a/samples/VirtualizationDemo/VirtualizationDemo.csproj b/samples/VirtualizationDemo/VirtualizationDemo.csproj index ce33f42143..817023fd71 100644 --- a/samples/VirtualizationDemo/VirtualizationDemo.csproj +++ b/samples/VirtualizationDemo/VirtualizationDemo.csproj @@ -10,7 +10,6 @@ - diff --git a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj index 3e318278c1..bd6b6f170f 100644 --- a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj +++ b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj @@ -26,7 +26,6 @@ - diff --git a/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj b/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj index 2f95a6e4bd..b8697e0ca2 100644 --- a/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj +++ b/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj @@ -149,7 +149,6 @@ - diff --git a/src/Avalonia.Base/AvaloniaObject.cs b/src/Avalonia.Base/AvaloniaObject.cs index f387d7e0b6..d18f0b3f94 100644 --- a/src/Avalonia.Base/AvaloniaObject.cs +++ b/src/Avalonia.Base/AvaloniaObject.cs @@ -421,8 +421,7 @@ namespace Avalonia throw new ArgumentException($"The property {property.Name} is readonly."); } - Logger.TryGet(LogEventLevel.Verbose)?.Log( - LogArea.Property, + Logger.TryGet(LogEventLevel.Verbose, LogArea.Property)?.Log( this, "Bound {Property} to {Binding} with priority LocalValue", property, @@ -501,8 +500,7 @@ namespace Avalonia if (change.IsEffectiveValueChange) { - Logger.TryGet(LogEventLevel.Verbose)?.Log( - LogArea.Property, + Logger.TryGet(LogEventLevel.Verbose, LogArea.Property)?.Log( this, "{Property} changed from {$Old} to {$Value} with priority {Priority}", property, @@ -586,8 +584,7 @@ namespace Avalonia /// The binding error. protected internal virtual void LogBindingError(AvaloniaProperty property, Exception e) { - Logger.TryGet(LogEventLevel.Warning)?.Log( - LogArea.Binding, + Logger.TryGet(LogEventLevel.Warning, LogArea.Binding)?.Log( this, "Error in binding to {Target}.{Property}: {Message}", this, @@ -857,8 +854,7 @@ namespace Avalonia /// The priority. private void LogPropertySet(AvaloniaProperty property, T value, BindingPriority priority) { - Logger.TryGet(LogEventLevel.Verbose)?.Log( - LogArea.Property, + Logger.TryGet(LogEventLevel.Verbose, LogArea.Property)?.Log( this, "Set {Property} to {$Value} with priority {Priority}", property, diff --git a/src/Avalonia.Base/Data/Core/BindingExpression.cs b/src/Avalonia.Base/Data/Core/BindingExpression.cs index 9721369e47..c4f61dfedb 100644 --- a/src/Avalonia.Base/Data/Core/BindingExpression.cs +++ b/src/Avalonia.Base/Data/Core/BindingExpression.cs @@ -168,8 +168,7 @@ namespace Avalonia.Data.Core } else { - Logger.TryGet(LogEventLevel.Error)?.Log( - LogArea.Binding, + Logger.TryGet(LogEventLevel.Error, LogArea.Binding)?.Log( this, "Could not convert FallbackValue {FallbackValue} to {Type}", _fallbackValue, diff --git a/src/Avalonia.Base/Logging/DebugLogSink.cs b/src/Avalonia.Base/Logging/DebugLogSink.cs new file mode 100644 index 0000000000..3695afa860 --- /dev/null +++ b/src/Avalonia.Base/Logging/DebugLogSink.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using Avalonia.Utilities; + +namespace Avalonia.Logging +{ + public class DebugLogSink : ILogSink + { + private readonly LogEventLevel _level; + private readonly IList _areas; + + public DebugLogSink( + LogEventLevel minimumLevel, + IList areas = null) + { + _level = minimumLevel; + _areas = areas?.Count > 0 ? areas : null; + } + + public bool IsEnabled(LogEventLevel level, string area) + { + return level >= _level && (_areas?.Contains(area) ?? true); + } + + public void Log(LogEventLevel level, string area, object source, string messageTemplate) + { + if (IsEnabled(level, area)) + { + Debug.WriteLine(Format(area, messageTemplate, source)); + } + } + + public void Log(LogEventLevel level, string area, object source, string messageTemplate, T0 propertyValue0) + { + if (IsEnabled(level, area)) + { + Debug.WriteLine(Format(area, messageTemplate, source, propertyValue0)); + } + } + + public void Log(LogEventLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + if (IsEnabled(level, area)) + { + Debug.WriteLine(Format(area, messageTemplate, source, propertyValue0, propertyValue1)); + } + } + + public void Log(LogEventLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) + { + if (IsEnabled(level, area)) + { + Debug.WriteLine(Format(area, messageTemplate, source, propertyValue0, propertyValue1, propertyValue2)); + } + } + + public void Log(LogEventLevel level, string area, object source, string messageTemplate, params object[] propertyValues) + { + if (IsEnabled(level, area)) + { + Debug.WriteLine(Format(area, messageTemplate, source, propertyValues)); + } + } + + private static string Format( + string area, + string template, + object source, + T0 v0 = default, + T1 v1 = default, + T2 v2 = default) + { + var result = new StringBuilder(template.Length); + var r = new CharacterReader(template.AsSpan()); + var i = 0; + + result.Append('['); + result.Append(area); + result.Append("] "); + + while (!r.End) + { + var c = r.Take(); + + if (c != '{') + { + result.Append(c); + } + else + { + if (r.Peek != '{') + { + result.Append('\''); + result.Append(i++ switch + { + 0 => v0, + 1 => v1, + 2 => v2, + _ => null + }); + result.Append('\''); + r.TakeUntil('}'); + r.Take(); + } + else + { + result.Append('{'); + r.Take(); + } + } + } + + if (source is object) + { + result.Append(" ("); + result.Append(source.GetType().Name); + result.Append(" #"); + result.Append(source.GetHashCode()); + result.Append(')'); + } + + return result.ToString(); + } + + private static string Format( + string area, + string template, + object source, + object[] v) + { + var result = new StringBuilder(template.Length); + var r = new CharacterReader(template.AsSpan()); + var i = 0; + + result.Append('['); + result.Append(area); + result.Append(']'); + + while (!r.End) + { + var c = r.Take(); + + if (c != '{') + { + result.Append(c); + } + else + { + if (r.Peek != '{') + { + result.Append('\''); + result.Append(i < v.Length ? v[i++] : null); + result.Append('\''); + r.TakeUntil('}'); + r.Take(); + } + else + { + result.Append('{'); + r.Take(); + } + } + } + + if (source is object) + { + result.Append('('); + result.Append(source.GetType().Name); + result.Append(" #"); + result.Append(source.GetHashCode()); + result.Append(')'); + } + + return result.ToString(); + } + } +} diff --git a/src/Avalonia.Base/Logging/ILogSink.cs b/src/Avalonia.Base/Logging/ILogSink.cs index 1649679b95..71268d5965 100644 --- a/src/Avalonia.Base/Logging/ILogSink.cs +++ b/src/Avalonia.Base/Logging/ILogSink.cs @@ -6,11 +6,12 @@ namespace Avalonia.Logging public interface ILogSink { /// - /// Checks if given log level is enabled. + /// Checks if given log level and area is enabled. /// /// The log event level. + /// The log area. /// if given log level is enabled. - bool IsEnabled(LogEventLevel level); + bool IsEnabled(LogEventLevel level, string area); /// /// Logs an event. diff --git a/src/Avalonia.Base/Logging/Logger.cs b/src/Avalonia.Base/Logging/Logger.cs index 136f56a620..ed3fad93fc 100644 --- a/src/Avalonia.Base/Logging/Logger.cs +++ b/src/Avalonia.Base/Logging/Logger.cs @@ -14,36 +14,39 @@ namespace Avalonia.Logging /// Checks if given log level is enabled. /// /// The log event level. + /// The log area. /// if given log level is enabled. - public static bool IsEnabled(LogEventLevel level) + public static bool IsEnabled(LogEventLevel level, string area) { - return Sink?.IsEnabled(level) == true; + return Sink?.IsEnabled(level, area) == true; } /// /// Returns parametrized logging sink if given log level is enabled. /// /// The log event level. + /// The area that the event originates from. /// Log sink or if log level is not enabled. - public static ParametrizedLogger? TryGet(LogEventLevel level) + public static ParametrizedLogger? TryGet(LogEventLevel level, string area) { - if (!IsEnabled(level)) + if (!IsEnabled(level, area)) { return null; } - return new ParametrizedLogger(Sink, level); + return new ParametrizedLogger(Sink, level, area); } /// /// Returns parametrized logging sink if given log level is enabled. /// /// The log event level. + /// The area that the event originates from. /// Log sink that is valid only if method returns . /// if logger was obtained successfully. - public static bool TryGet(LogEventLevel level, out ParametrizedLogger outLogger) + public static bool TryGet(LogEventLevel level, string area, out ParametrizedLogger outLogger) { - ParametrizedLogger? logger = TryGet(level); + ParametrizedLogger? logger = TryGet(level, area); outLogger = logger.GetValueOrDefault(); diff --git a/src/Avalonia.Base/Logging/ParametrizedLogger.cs b/src/Avalonia.Base/Logging/ParametrizedLogger.cs index 3dfb3c1ecf..adadb0f990 100644 --- a/src/Avalonia.Base/Logging/ParametrizedLogger.cs +++ b/src/Avalonia.Base/Logging/ParametrizedLogger.cs @@ -9,11 +9,13 @@ namespace Avalonia.Logging { private readonly ILogSink _sink; private readonly LogEventLevel _level; + private readonly string _area; - public ParametrizedLogger(ILogSink sink, LogEventLevel level) + public ParametrizedLogger(ILogSink sink, LogEventLevel level, string area) { _sink = sink; _level = level; + _area = area; } /// @@ -24,58 +26,51 @@ namespace Avalonia.Logging /// /// Logs an event. /// - /// The area that the event originates. /// The object from which the event originates. /// The message template. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Log( - string area, object source, string messageTemplate) { - _sink.Log(_level, area, source, messageTemplate); + _sink.Log(_level, _area, source, messageTemplate); } /// /// Logs an event. /// - /// The area that the event originates. /// The object from which the event originates. /// The message template. /// Message property value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Log( - string area, object source, string messageTemplate, T0 propertyValue0) { - _sink.Log(_level, area, source, messageTemplate, propertyValue0); + _sink.Log(_level, _area, source, messageTemplate, propertyValue0); } /// /// Logs an event. /// - /// The area that the event originates. /// The object from which the event originates. /// The message template. /// Message property value. /// Message property value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Log( - string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { - _sink.Log(_level, area, source, messageTemplate, propertyValue0, propertyValue1); + _sink.Log(_level, _area, source, messageTemplate, propertyValue0, propertyValue1); } /// /// Logs an event. /// - /// The area that the event originates. /// The object from which the event originates. /// The message template. /// Message property value. @@ -83,20 +78,18 @@ namespace Avalonia.Logging /// Message property value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Log( - string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { - _sink.Log(_level, area, source, messageTemplate, propertyValue0, propertyValue1, propertyValue2); + _sink.Log(_level, _area, source, messageTemplate, propertyValue0, propertyValue1, propertyValue2); } /// /// Logs an event. /// - /// The area that the event originates. /// The object from which the event originates. /// The message template. /// Message property value. @@ -105,7 +98,6 @@ namespace Avalonia.Logging /// Message property value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Log( - string area, object source, string messageTemplate, T0 propertyValue0, @@ -113,13 +105,12 @@ namespace Avalonia.Logging T2 propertyValue2, T3 propertyValue3) { - _sink.Log(_level, area, source, messageTemplate, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + _sink.Log(_level, _area, source, messageTemplate, propertyValue0, propertyValue1, propertyValue2, propertyValue3); } /// /// Logs an event. /// - /// The area that the event originates. /// The object from which the event originates. /// The message template. /// Message property value. @@ -129,7 +120,6 @@ namespace Avalonia.Logging /// Message property value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Log( - string area, object source, string messageTemplate, T0 propertyValue0, @@ -138,13 +128,12 @@ namespace Avalonia.Logging T3 propertyValue3, T4 propertyValue4) { - _sink.Log(_level, area, source, messageTemplate, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + _sink.Log(_level, _area, source, messageTemplate, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); } /// /// Logs an event. /// - /// The area that the event originates. /// The object from which the event originates. /// The message template. /// Message property value. @@ -155,7 +144,6 @@ namespace Avalonia.Logging /// Message property value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Log( - string area, object source, string messageTemplate, T0 propertyValue0, @@ -165,7 +153,7 @@ namespace Avalonia.Logging T4 propertyValue4, T5 propertyValue5) { - _sink.Log(_level, area, source, messageTemplate, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + _sink.Log(_level, _area, source, messageTemplate, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); } } } diff --git a/src/Avalonia.Base/Reactive/TypedBindingAdapter.cs b/src/Avalonia.Base/Reactive/TypedBindingAdapter.cs index bd9b31b100..b99cef0f51 100644 --- a/src/Avalonia.Base/Reactive/TypedBindingAdapter.cs +++ b/src/Avalonia.Base/Reactive/TypedBindingAdapter.cs @@ -32,8 +32,7 @@ namespace Avalonia.Reactive } catch (InvalidCastException e) { - Logger.TryGet(LogEventLevel.Error)?.Log( - LogArea.Binding, + Logger.TryGet(LogEventLevel.Error, LogArea.Binding)?.Log( _target, "Binding produced invalid value for {$Property} ({$PropertyType}): {$Value} ({$ValueType})", _property.Name, diff --git a/src/Avalonia.Controls/DropDown.cs b/src/Avalonia.Controls/DropDown.cs index 9da803d16d..4e17f5bff5 100644 --- a/src/Avalonia.Controls/DropDown.cs +++ b/src/Avalonia.Controls/DropDown.cs @@ -9,7 +9,7 @@ namespace Avalonia.Controls { public DropDown() { - Logger.TryGet(LogEventLevel.Warning)?.Log(LogArea.Control, this, "DropDown is deprecated: Use ComboBox"); + Logger.TryGet(LogEventLevel.Warning, LogArea.Control)?.Log(this, "DropDown is deprecated: Use ComboBox"); } Type IStyleable.StyleKey => typeof(ComboBox); @@ -20,7 +20,7 @@ namespace Avalonia.Controls { public DropDownItem() { - Logger.TryGet(LogEventLevel.Warning)?.Log(LogArea.Control, this, "DropDownItem is deprecated: Use ComboBoxItem"); + Logger.TryGet(LogEventLevel.Warning, LogArea.Control)?.Log(this, "DropDownItem is deprecated: Use ComboBoxItem"); } Type IStyleable.StyleKey => typeof(ComboBoxItem); diff --git a/src/Avalonia.Controls/LoggingExtensions.cs b/src/Avalonia.Controls/LoggingExtensions.cs new file mode 100644 index 0000000000..44e570bdfa --- /dev/null +++ b/src/Avalonia.Controls/LoggingExtensions.cs @@ -0,0 +1,26 @@ +using Avalonia.Controls; +using Avalonia.Logging; + +namespace Avalonia +{ + public static class LoggingExtensions + { + /// + /// Logs Avalonia events to the sink. + /// + /// The application class type. + /// The app builder instance. + /// The minimum level to log. + /// The areas to log. Valid values are listed in . + /// The app builder instance. + public static T LogToDebug( + this T builder, + LogEventLevel level = LogEventLevel.Warning, + params string[] areas) + where T : AppBuilderBase, new() + { + Logger.Sink = new DebugLogSink(level, areas); + return builder; + } + } +} diff --git a/src/Avalonia.Controls/Primitives/TemplatedControl.cs b/src/Avalonia.Controls/Primitives/TemplatedControl.cs index 820d5777f5..d18cf7da71 100644 --- a/src/Avalonia.Controls/Primitives/TemplatedControl.cs +++ b/src/Avalonia.Controls/Primitives/TemplatedControl.cs @@ -252,7 +252,7 @@ namespace Avalonia.Controls.Primitives if (template != null) { - Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Control, this, "Creating control template"); + Logger.TryGet(LogEventLevel.Verbose, LogArea.Control)?.Log(this, "Creating control template"); var (child, nameScope) = template.Build(this); ApplyTemplatedParent(child); diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs index e431076d2c..5d34444eb8 100644 --- a/src/Avalonia.Controls/TopLevel.cs +++ b/src/Avalonia.Controls/TopLevel.cs @@ -449,8 +449,7 @@ namespace Avalonia.Controls if (result == null) { - Logger.TryGet(LogEventLevel.Warning)?.Log( - LogArea.Control, + Logger.TryGet(LogEventLevel.Warning, LogArea.Control)?.Log( this, "Could not create {Service} : maybe Application.RegisterServices() wasn't called?", typeof(T)); diff --git a/src/Avalonia.Layout/LayoutManager.cs b/src/Avalonia.Layout/LayoutManager.cs index 908758045a..1c0c736b78 100644 --- a/src/Avalonia.Layout/LayoutManager.cs +++ b/src/Avalonia.Layout/LayoutManager.cs @@ -80,12 +80,11 @@ namespace Avalonia.Layout Stopwatch? stopwatch = null; const LogEventLevel timingLogLevel = LogEventLevel.Information; - bool captureTiming = Logger.IsEnabled(timingLogLevel); + bool captureTiming = Logger.IsEnabled(timingLogLevel, LogArea.Layout); if (captureTiming) { - Logger.TryGet(timingLogLevel)?.Log( - LogArea.Layout, + Logger.TryGet(timingLogLevel, LogArea.Layout)?.Log( this, "Started layout pass. To measure: {Measure} To arrange: {Arrange}", _toMeasure.Count, @@ -123,7 +122,7 @@ namespace Avalonia.Layout { stopwatch!.Stop(); - Logger.TryGet(timingLogLevel)?.Log(LogArea.Layout, this, "Layout pass finished in {Time}", stopwatch.Elapsed); + Logger.TryGet(timingLogLevel, LogArea.Layout)?.Log(this, "Layout pass finished in {Time}", stopwatch.Elapsed); } } diff --git a/src/Avalonia.Layout/Layoutable.cs b/src/Avalonia.Layout/Layoutable.cs index 513d3d540e..8d2a825fa0 100644 --- a/src/Avalonia.Layout/Layoutable.cs +++ b/src/Avalonia.Layout/Layoutable.cs @@ -349,7 +349,7 @@ namespace Avalonia.Layout DesiredSize = desiredSize; _previousMeasure = availableSize; - Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Layout, this, "Measure requested {DesiredSize}", DesiredSize); + Logger.TryGet(LogEventLevel.Verbose, LogArea.Layout)?.Log(this, "Measure requested {DesiredSize}", DesiredSize); if (DesiredSize != previousDesiredSize) { @@ -376,7 +376,7 @@ namespace Avalonia.Layout if (!IsArrangeValid || _previousArrange != rect) { - Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Layout, this, "Arrange to {Rect} ", rect); + Logger.TryGet(LogEventLevel.Verbose, LogArea.Layout)?.Log(this, "Arrange to {Rect} ", rect); IsArrangeValid = true; ArrangeCore(rect); @@ -398,7 +398,7 @@ namespace Avalonia.Layout { if (IsMeasureValid) { - Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Layout, this, "Invalidated measure"); + Logger.TryGet(LogEventLevel.Verbose, LogArea.Layout)?.Log(this, "Invalidated measure"); IsMeasureValid = false; IsArrangeValid = false; @@ -419,7 +419,7 @@ namespace Avalonia.Layout { if (IsArrangeValid) { - Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Layout, this, "Invalidated arrange"); + Logger.TryGet(LogEventLevel.Verbose, LogArea.Layout)?.Log(this, "Invalidated arrange"); IsArrangeValid = false; (VisualRoot as ILayoutRoot)?.LayoutManager?.InvalidateArrange(this); diff --git a/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj b/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj deleted file mode 100644 index 3e76001556..0000000000 --- a/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - netstandard2.0 - - - - - - - diff --git a/src/Avalonia.Logging.Serilog/SerilogExtensions.cs b/src/Avalonia.Logging.Serilog/SerilogExtensions.cs deleted file mode 100644 index 2ce38769da..0000000000 --- a/src/Avalonia.Logging.Serilog/SerilogExtensions.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using Avalonia.Controls; -using Serilog; -using Serilog.Configuration; -using Serilog.Filters; -using SerilogLevel = Serilog.Events.LogEventLevel; - -namespace Avalonia.Logging.Serilog -{ - /// - /// Extension methods for Serilog logging. - /// - public static class SerilogExtensions - { - private const string DefaultTemplate = "[{Area}] {Message} ({SourceType} #{SourceHash})"; - - /// - /// Logs Avalonia events to the sink. - /// - /// The application class type. - /// The app builder instance. - /// The minimum level to log. - /// The app builder instance. - public static T LogToDebug( - this T builder, - LogEventLevel level = LogEventLevel.Warning) - where T : AppBuilderBase, new() - { - SerilogLogger.Initialize(new LoggerConfiguration() - .MinimumLevel.Is((SerilogLevel)level) - .Enrich.FromLogContext() - .WriteTo.Debug(outputTemplate: DefaultTemplate) - .CreateLogger()); - return builder; - } - - /// - /// Logs Avalonia events to the sink. - /// - /// The application class type. - /// The app builder instance. - /// The area to log. Valid values are listed in . - /// The minimum level to log. - /// The app builder instance. - public static T LogToDebug( - this T builder, - string area, - LogEventLevel level = LogEventLevel.Warning) - where T : AppBuilderBase, new() - { - SerilogLogger.Initialize(new LoggerConfiguration() - .MinimumLevel.Is((SerilogLevel)level) - .Filter.ByIncludingOnly(Matching.WithProperty("Area", area)) - .Enrich.FromLogContext() - .WriteTo.Debug(outputTemplate: DefaultTemplate) - .CreateLogger()); - return builder; - } - - /// - /// Logs Avalonia events to the sink. - /// - /// The application class type. - /// The app builder instance. - /// The minimum level to log. - /// The app builder instance. - public static T LogToTrace( - this T builder, - LogEventLevel level = LogEventLevel.Warning) - where T : AppBuilderBase, new() - { - SerilogLogger.Initialize(new LoggerConfiguration() - .MinimumLevel.Is((SerilogLevel)level) - .Enrich.FromLogContext() - .WriteTo.Trace(outputTemplate: DefaultTemplate) - .CreateLogger()); - return builder; - } - - /// - /// Logs Avalonia events to the sink. - /// - /// The application class type. - /// The app builder instance. - /// The area to log. Valid values are listed in . - /// The minimum level to log. - /// The app builder instance. - public static T LogToTrace( - this T builder, - string area, - LogEventLevel level = LogEventLevel.Warning) - where T : AppBuilderBase, new() - { - SerilogLogger.Initialize(new LoggerConfiguration() - .MinimumLevel.Is((SerilogLevel)level) - .Filter.ByIncludingOnly(Matching.WithProperty("Area", area)) - .Enrich.FromLogContext() - .WriteTo.Trace(outputTemplate: DefaultTemplate) - .CreateLogger()); - return builder; - } - } -} diff --git a/src/Avalonia.Logging.Serilog/SerilogLogger.cs b/src/Avalonia.Logging.Serilog/SerilogLogger.cs deleted file mode 100644 index e51925a0f2..0000000000 --- a/src/Avalonia.Logging.Serilog/SerilogLogger.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System; -using Serilog; -using Serilog.Context; -using AvaloniaLogEventLevel = Avalonia.Logging.LogEventLevel; -using SerilogLogEventLevel = Serilog.Events.LogEventLevel; - -namespace Avalonia.Logging.Serilog -{ - /// - /// Sends log output to serilog. - /// - public class SerilogLogger : ILogSink - { - private readonly ILogger _output; - - /// - /// Initializes a new instance of the class. - /// - /// The serilog logger to use. - public SerilogLogger(ILogger output) - { - _output = output; - } - - /// - /// Initializes the Avalonia logging with a new instance of a . - /// - /// The serilog logger to use. - public static void Initialize(ILogger output) - { - Logger.Sink = new SerilogLogger(output); - } - - public bool IsEnabled(LogEventLevel level) - { - return _output.IsEnabled((SerilogLogEventLevel)level); - } - - public void Log( - LogEventLevel level, - string area, - object source, - string messageTemplate) - { - Contract.Requires(area != null); - Contract.Requires(messageTemplate != null); - - using (PushLogContextProperties(area, source)) - { - _output.Write((SerilogLogEventLevel)level, messageTemplate); - } - } - - public void Log( - LogEventLevel level, - string area, object source, - string messageTemplate, - T0 propertyValue0) - { - Contract.Requires(area != null); - Contract.Requires(messageTemplate != null); - - using (PushLogContextProperties(area, source)) - { - _output.Write((SerilogLogEventLevel)level, messageTemplate, propertyValue0); - } - } - - public void Log( - LogEventLevel level, - string area, - object source, - string messageTemplate, - T0 propertyValue0, - T1 propertyValue1) - { - Contract.Requires(area != null); - Contract.Requires(messageTemplate != null); - - using (PushLogContextProperties(area, source)) - { - _output.Write((SerilogLogEventLevel)level, messageTemplate, propertyValue0, propertyValue1); - } - } - - public void Log( - LogEventLevel level, - string area, - object source, - string messageTemplate, - T0 propertyValue0, - T1 propertyValue1, - T2 propertyValue2) - { - Contract.Requires(area != null); - Contract.Requires(messageTemplate != null); - - using (PushLogContextProperties(area, source)) - { - _output.Write((SerilogLogEventLevel)level, messageTemplate, propertyValue0, propertyValue1, propertyValue2); - } - } - - /// - public void Log( - AvaloniaLogEventLevel level, - string area, - object source, - string messageTemplate, - params object[] propertyValues) - { - Contract.Requires(area != null); - Contract.Requires(messageTemplate != null); - - using (PushLogContextProperties(area, source)) - { - _output.Write((SerilogLogEventLevel)level, messageTemplate, propertyValues); - } - } - - private static LogContextDisposable PushLogContextProperties(string area, object source) - { - return new LogContextDisposable( - LogContext.PushProperty("Area", area), - LogContext.PushProperty("SourceType", source?.GetType()), - LogContext.PushProperty("SourceHash", source?.GetHashCode()) - ); - } - - private readonly struct LogContextDisposable : IDisposable - { - private readonly IDisposable _areaDisposable; - private readonly IDisposable _sourceTypeDisposable; - private readonly IDisposable _sourceHashDisposable; - - public LogContextDisposable(IDisposable areaDisposable, IDisposable sourceTypeDisposable, IDisposable sourceHashDisposable) - { - _areaDisposable = areaDisposable; - _sourceTypeDisposable = sourceTypeDisposable; - _sourceHashDisposable = sourceHashDisposable; - } - - public void Dispose() - { - _areaDisposable.Dispose(); - _sourceTypeDisposable.Dispose(); - _sourceHashDisposable.Dispose(); - } - } - } -} diff --git a/src/Avalonia.OpenGL/EglGlPlatformFeature.cs b/src/Avalonia.OpenGL/EglGlPlatformFeature.cs index cf3bce8756..f59c6b7751 100644 --- a/src/Avalonia.OpenGL/EglGlPlatformFeature.cs +++ b/src/Avalonia.OpenGL/EglGlPlatformFeature.cs @@ -34,7 +34,7 @@ namespace Avalonia.OpenGL } catch(Exception e) { - Logger.TryGet(LogEventLevel.Error)?.Log("OpenGL", null, "Unable to initialize EGL-based rendering: {0}", e); + Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log(null, "Unable to initialize EGL-based rendering: {0}", e); return null; } } diff --git a/src/Avalonia.OpenGL/OpenGlControlBase.cs b/src/Avalonia.OpenGL/OpenGlControlBase.cs index 6268c81516..8567dcae20 100644 --- a/src/Avalonia.OpenGL/OpenGlControlBase.cs +++ b/src/Avalonia.OpenGL/OpenGlControlBase.cs @@ -94,7 +94,7 @@ namespace Avalonia.OpenGL } catch (Exception e) { - Logger.TryGet(LogEventLevel.Error)?.Log("OpenGL", "OpenGlControlBase", + Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log("OpenGlControlBase", "Unable to initialize OpenGL: unable to create additional OpenGL context: {exception}", e); _glFailed = true; return false; @@ -109,7 +109,7 @@ namespace Avalonia.OpenGL { _context.Dispose(); _context = null; - Logger.TryGet(LogEventLevel.Error)?.Log("OpenGL", "OpenGlControlBase", + Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log("OpenGlControlBase", "Unable to initialize OpenGL: unable to create OpenGlTextureBitmap: {exception}", e); _glFailed = true; return false; @@ -138,7 +138,7 @@ namespace Avalonia.OpenGL { int code; while ((code = gl.GetError()) != 0) - Logger.TryGet(LogEventLevel.Error)?.Log("OpenGL", "OpenGlControlBase", + Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log("OpenGlControlBase", "Unable to initialize OpenGL FBO: {code}", code); _glFailed = true; @@ -147,7 +147,7 @@ namespace Avalonia.OpenGL } catch(Exception e) { - Logger.TryGet(LogEventLevel.Error)?.Log("OpenGL", "OpenGlControlBase", + Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log("OpenGlControlBase", "Unable to initialize OpenGL FBO: {exception}", e); _glFailed = true; } diff --git a/src/Avalonia.Styling/StyledElement.cs b/src/Avalonia.Styling/StyledElement.cs index bdd01924f1..05e031c9ec 100644 --- a/src/Avalonia.Styling/StyledElement.cs +++ b/src/Avalonia.Styling/StyledElement.cs @@ -689,8 +689,7 @@ namespace Avalonia #if DEBUG if (((INotifyCollectionChangedDebug)Classes).GetCollectionChangedSubscribers()?.Length > 0) { - Logger.TryGet(LogEventLevel.Warning)?.Log( - LogArea.Control, + Logger.TryGet(LogEventLevel.Warning, LogArea.Control)?.Log( this, "{Type} detached from logical tree but still has class listeners", GetType()); diff --git a/src/Avalonia.Visuals/Animation/Animators/TransformAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/TransformAnimator.cs index bb1c0da902..1b2142f6c9 100644 --- a/src/Avalonia.Visuals/Animation/Animators/TransformAnimator.cs +++ b/src/Avalonia.Visuals/Animation/Animators/TransformAnimator.cs @@ -73,15 +73,13 @@ namespace Avalonia.Animation.Animators } } - Logger.TryGet(LogEventLevel.Warning)?.Log( - LogArea.Animations, + Logger.TryGet(LogEventLevel.Warning, LogArea.Animations)?.Log( control, $"Cannot find the appropriate transform: \"{Property.OwnerType}\" in {control}."); } else { - Logger.TryGet(LogEventLevel.Error)?.Log( - LogArea.Animations, + Logger.TryGet(LogEventLevel.Error, LogArea.Animations)?.Log( control, $"Cannot apply animation: Target property owner {Property.OwnerType} is not a Transform object."); } diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs index 59dd369956..8c020fc073 100644 --- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs @@ -287,7 +287,7 @@ namespace Avalonia.Rendering } catch (RenderTargetCorruptedException ex) { - Logger.TryGet(LogEventLevel.Information)?.Log("Renderer", this, "Render target was corrupted. Exception: {0}", ex); + Logger.TryGet(LogEventLevel.Information, LogArea.Animations)?.Log(this, "Render target was corrupted. Exception: {0}", ex); RenderTarget?.Dispose(); RenderTarget = null; } diff --git a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs index b1f51b941a..9ea1b84311 100644 --- a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs @@ -78,7 +78,7 @@ namespace Avalonia.Rendering } catch (RenderTargetCorruptedException ex) { - Logger.TryGet(LogEventLevel.Information)?.Log("Renderer", this, "Render target was corrupted. Exception: {0}", ex); + Logger.TryGet(LogEventLevel.Information, LogArea.Animations)?.Log(this, "Render target was corrupted. Exception: {0}", ex); _renderTarget.Dispose(); _renderTarget = null; } diff --git a/src/Avalonia.Visuals/Rendering/RenderLoop.cs b/src/Avalonia.Visuals/Rendering/RenderLoop.cs index c2594658b9..789d028a3a 100644 --- a/src/Avalonia.Visuals/Rendering/RenderLoop.cs +++ b/src/Avalonia.Visuals/Rendering/RenderLoop.cs @@ -120,7 +120,7 @@ namespace Avalonia.Rendering } catch (Exception ex) { - Logger.TryGet(LogEventLevel.Error)?.Log(LogArea.Visual, this, "Exception in render update: {Error}", ex); + Logger.TryGet(LogEventLevel.Error, LogArea.Visual)?.Log(this, "Exception in render update: {Error}", ex); } } } @@ -136,7 +136,7 @@ namespace Avalonia.Rendering } catch (Exception ex) { - Logger.TryGet(LogEventLevel.Error)?.Log(LogArea.Visual, this, "Exception in render loop: {Error}", ex); + Logger.TryGet(LogEventLevel.Error, LogArea.Visual)?.Log(this, "Exception in render loop: {Error}", ex); } finally { diff --git a/src/Avalonia.Visuals/Visual.cs b/src/Avalonia.Visuals/Visual.cs index cd6e5bb075..cd6eb6aac7 100644 --- a/src/Avalonia.Visuals/Visual.cs +++ b/src/Avalonia.Visuals/Visual.cs @@ -387,7 +387,7 @@ namespace Avalonia /// The event args. protected virtual void OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e) { - Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Visual, this, "Attached to visual tree"); + Logger.TryGet(LogEventLevel.Verbose, LogArea.Visual)?.Log(this, "Attached to visual tree"); _visualRoot = e.Root; @@ -424,7 +424,7 @@ namespace Avalonia /// The event args. protected virtual void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e) { - Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Visual, this, "Detached from visual tree"); + Logger.TryGet(LogEventLevel.Verbose, LogArea.Visual)?.Log(this, "Detached from visual tree"); _visualRoot = null; @@ -501,8 +501,7 @@ namespace Avalonia return; } - Logger.TryGet(LogEventLevel.Warning)?.Log( - LogArea.Binding, + Logger.TryGet(LogEventLevel.Warning, LogArea.Binding)?.Log( this, "Error in binding to {Target}.{Property}: {Message}", this, diff --git a/src/Avalonia.X11/Glx/GlxPlatformFeature.cs b/src/Avalonia.X11/Glx/GlxPlatformFeature.cs index 046036fd68..e3250e6733 100644 --- a/src/Avalonia.X11/Glx/GlxPlatformFeature.cs +++ b/src/Avalonia.X11/Glx/GlxPlatformFeature.cs @@ -37,7 +37,7 @@ namespace Avalonia.X11.Glx } catch(Exception e) { - Logger.TryGet(LogEventLevel.Error)?.Log("OpenGL", null, "Unable to initialize GLX-based rendering: {0}", e); + Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log(null, "Unable to initialize GLX-based rendering: {0}", e); return null; } } diff --git a/src/Markup/Avalonia.Markup.Xaml/Converters/AvaloniaPropertyTypeConverter.cs b/src/Markup/Avalonia.Markup.Xaml/Converters/AvaloniaPropertyTypeConverter.cs index cd67b27ff3..45ca1c4adc 100644 --- a/src/Markup/Avalonia.Markup.Xaml/Converters/AvaloniaPropertyTypeConverter.cs +++ b/src/Markup/Avalonia.Markup.Xaml/Converters/AvaloniaPropertyTypeConverter.cs @@ -39,8 +39,7 @@ namespace Avalonia.Markup.Xaml.Converters !property.IsAttached && !registry.IsRegistered(targetType, property)) { - Logger.TryGet(LogEventLevel.Warning)?.Log( - LogArea.Property, + Logger.TryGet(LogEventLevel.Warning, LogArea.Property)?.Log( this, "Property '{Owner}.{Name}' is not registered on '{Type}'.", effectiveOwner, diff --git a/src/Markup/Avalonia.Markup/Markup/Data/DelayedBinding.cs b/src/Markup/Avalonia.Markup/Markup/Data/DelayedBinding.cs index ebb544bcca..0b0ed7b06a 100644 --- a/src/Markup/Avalonia.Markup/Markup/Data/DelayedBinding.cs +++ b/src/Markup/Avalonia.Markup/Markup/Data/DelayedBinding.cs @@ -147,8 +147,7 @@ namespace Avalonia.Markup.Data } catch (Exception e) { - Logger.TryGet(LogEventLevel.Error)?.Log( - LogArea.Property, + Logger.TryGet(LogEventLevel.Error, LogArea.Property)?.Log( control, "Error setting {Property} on {Target}: {Exception}", Property.Name, diff --git a/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs index cca014bda5..e1f7aad1b2 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs @@ -82,8 +82,7 @@ namespace Avalonia.Direct2D1.Media } catch (Exception ex) { - Logger.TryGet(LogEventLevel.Error)?.Log( - LogArea.Visual, + Logger.TryGet(LogEventLevel.Error, LogArea.Visual)?.Log( this, "GeometrySink.Close exception: {Exception}", ex); diff --git a/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj b/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj index 73a1d586b5..523c5e7ff4 100644 --- a/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj +++ b/tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj @@ -32,5 +32,4 @@ - diff --git a/tests/Avalonia.UnitTests/TestLogSink.cs b/tests/Avalonia.UnitTests/TestLogSink.cs index 5c1dd293c4..e10292a59b 100644 --- a/tests/Avalonia.UnitTests/TestLogSink.cs +++ b/tests/Avalonia.UnitTests/TestLogSink.cs @@ -27,7 +27,7 @@ namespace Avalonia.UnitTests return Disposable.Create(() => Logger.Sink = null); } - public bool IsEnabled(LogEventLevel level) + public bool IsEnabled(LogEventLevel level, string area) { return true; }