diff --git a/Avalonia.sln b/Avalonia.sln
index c6509817ce..a29f3dd754 100644
--- a/Avalonia.sln
+++ b/Avalonia.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.26730.10
+VisualStudioVersion = 15.0.27004.2008
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Base", "src\Avalonia.Base\Avalonia.Base.csproj", "{B09B78D8-9B26-48B0-9149-D64A2F120F3F}"
EndProject
@@ -155,7 +155,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{F3AC8BC1
build\ReactiveUI.props = build\ReactiveUI.props
build\Rx.props = build\Rx.props
build\Serilog.props = build\Serilog.props
- build\Serilog.Sinks.Trace.props = build\Serilog.Sinks.Trace.props
build\SharpDX.props = build\SharpDX.props
build\SkiaSharp.Desktop.props = build\SkiaSharp.Desktop.props
build\SkiaSharp.props = build\SkiaSharp.props
diff --git a/build/Serilog.Sinks.Trace.props b/build/Serilog.Sinks.Trace.props
deleted file mode 100644
index ef79fd7669..0000000000
--- a/build/Serilog.Sinks.Trace.props
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/build/Serilog.props b/build/Serilog.props
index e9bd39f6af..a814cf998d 100644
--- a/build/Serilog.props
+++ b/build/Serilog.props
@@ -1,5 +1,7 @@
-
+
+
+
diff --git a/packages.cake b/packages.cake
index 9e78ee75d5..bc290fce22 100644
--- a/packages.cake
+++ b/packages.cake
@@ -107,6 +107,8 @@ public class Packages
context.Information("Setting NuGet package dependencies versions:");
var SerilogVersion = packageVersions["Serilog"].FirstOrDefault().Item1;
+ var SerilogSinksDebugVersion = packageVersions["Serilog.Sinks.Debug"].FirstOrDefault().Item1;
+ var SerilogSinksTraceVersion = packageVersions["Serilog.Sinks.Trace"].FirstOrDefault().Item1;
var SpracheVersion = packageVersions["Sprache"].FirstOrDefault().Item1;
var SystemReactiveVersion = packageVersions["System.Reactive"].FirstOrDefault().Item1;
var ReactiveUIVersion = packageVersions["reactiveui"].FirstOrDefault().Item1;
@@ -243,6 +245,8 @@ public class Packages
Dependencies = new DependencyBuilder(this)
{
new NuSpecDependency() { Id = "Serilog", Version = SerilogVersion },
+ new NuSpecDependency() { Id = "Serilog.Sinks.Debug", Version = SerilogSinksDebugVersion },
+ new NuSpecDependency() { Id = "Serilog.Sinks.Trace", Version = SerilogSinksTraceVersion },
new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion },
new NuSpecDependency() { Id = "System.Reactive", Version = SystemReactiveVersion },
new NuSpecDependency() { Id = "Avalonia.Remote.Protocol", Version = parameters.Version },
@@ -251,6 +255,8 @@ public class Packages
new NuSpecDependency() { Id = "Microsoft.Extensions.DependencyModel", TargetFramework = "netcoreapp2.0", Version = "1.1.0" },
new NuSpecDependency() { Id = "NETStandard.Library", TargetFramework = "netcoreapp2.0", Version = "1.6.0" },
new NuSpecDependency() { Id = "Serilog", TargetFramework = "netcoreapp2.0", Version = SerilogVersion },
+ new NuSpecDependency() { Id = "Serilog.Sinks.Debug", TargetFramework = "netcoreapp2.0", Version = SerilogSinksDebugVersion },
+ new NuSpecDependency() { Id = "Serilog.Sinks.Trace", TargetFramework = "netcoreapp2.0", Version = SerilogSinksTraceVersion },
new NuSpecDependency() { Id = "Sprache", TargetFramework = "netcoreapp2.0", Version = SpracheVersion },
new NuSpecDependency() { Id = "System.Reactive", TargetFramework = "netcoreapp2.0", Version = SystemReactiveVersion },
new NuSpecDependency() { Id = "Avalonia.Remote.Protocol", TargetFramework = "netcoreapp2.0", Version = parameters.Version },
diff --git a/samples/BindingTest/App.xaml.cs b/samples/BindingTest/App.xaml.cs
index 42e5716541..ccad1d0ba9 100644
--- a/samples/BindingTest/App.xaml.cs
+++ b/samples/BindingTest/App.xaml.cs
@@ -16,22 +16,11 @@ namespace BindingTest
private static void Main()
{
- InitializeLogging();
-
AppBuilder.Configure()
.UsePlatformDetect()
.UseReactiveUI()
+ .LogToDebug()
.Start();
}
-
- private static void InitializeLogging()
- {
-#if DEBUG
- SerilogLogger.Initialize(new LoggerConfiguration()
- .MinimumLevel.Warning()
- .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
- .CreateLogger());
-#endif
- }
}
}
diff --git a/samples/BindingTest/BindingTest.csproj b/samples/BindingTest/BindingTest.csproj
index 4f82303c3a..9f3fed5522 100644
--- a/samples/BindingTest/BindingTest.csproj
+++ b/samples/BindingTest/BindingTest.csproj
@@ -151,7 +151,6 @@
-
\ No newline at end of file
diff --git a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj
index 3f4679086e..cfa2f89b0e 100644
--- a/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj
+++ b/samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj
@@ -135,5 +135,4 @@
-
\ No newline at end of file
diff --git a/samples/ControlCatalog.Desktop/Program.cs b/samples/ControlCatalog.Desktop/Program.cs
index 20bf4ed342..b151cabf43 100644
--- a/samples/ControlCatalog.Desktop/Program.cs
+++ b/samples/ControlCatalog.Desktop/Program.cs
@@ -12,8 +12,6 @@ namespace ControlCatalog
{
static void Main(string[] args)
{
- InitializeLogging();
-
// TODO: Make this work with GTK/Skia/Cairo depending on command-line args
// again.
BuildAvaloniaApp().Start();
@@ -23,18 +21,7 @@ namespace ControlCatalog
/// This method is needed for IDE previewer infrastructure
///
public static AppBuilder BuildAvaloniaApp()
- => AppBuilder.Configure().UsePlatformDetect();
-
- // This will be made into a runtime configuration extension soon!
- private static void InitializeLogging()
- {
-#if DEBUG
- SerilogLogger.Initialize(new LoggerConfiguration()
- .MinimumLevel.Warning()
- .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
- .CreateLogger());
-#endif
- }
+ => AppBuilder.Configure().LogToDebug().UsePlatformDetect();
private static void ConfigureAssetAssembly(AppBuilder builder)
{
diff --git a/samples/RenderTest/Program.cs b/samples/RenderTest/Program.cs
index 514771097f..a1a2b8c410 100644
--- a/samples/RenderTest/Program.cs
+++ b/samples/RenderTest/Program.cs
@@ -12,25 +12,13 @@ namespace RenderTest
{
static void Main(string[] args)
{
- InitializeLogging();
-
// TODO: Make this work with GTK/Skia/Cairo depending on command-line args
// again.
AppBuilder.Configure()
.UsePlatformDetect()
.UseReactiveUI()
+ .LogToDebug()
.Start();
}
-
- // This will be made into a runtime configuration extension soon!
- private static void InitializeLogging()
- {
-#if DEBUG
- SerilogLogger.Initialize(new LoggerConfiguration()
- .MinimumLevel.Warning()
- .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
- .CreateLogger());
-#endif
- }
}
}
diff --git a/samples/RenderTest/RenderTest.csproj b/samples/RenderTest/RenderTest.csproj
index a71f17ab7a..4a471a831a 100644
--- a/samples/RenderTest/RenderTest.csproj
+++ b/samples/RenderTest/RenderTest.csproj
@@ -180,7 +180,6 @@
-
\ No newline at end of file
diff --git a/samples/VirtualizationTest/Program.cs b/samples/VirtualizationTest/Program.cs
index e9156d803f..097f0cfdc7 100644
--- a/samples/VirtualizationTest/Program.cs
+++ b/samples/VirtualizationTest/Program.cs
@@ -13,22 +13,11 @@ namespace VirtualizationTest
{
static void Main(string[] args)
{
- InitializeLogging();
-
AppBuilder.Configure()
.UsePlatformDetect()
.UseReactiveUI()
+ .LogToDebug()
.Start();
}
-
- private static void InitializeLogging()
- {
-#if DEBUG
- SerilogLogger.Initialize(new LoggerConfiguration()
- .MinimumLevel.Warning()
- .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
- .CreateLogger());
-#endif
- }
}
}
diff --git a/samples/VirtualizationTest/VirtualizationTest.csproj b/samples/VirtualizationTest/VirtualizationTest.csproj
index 6d3803b4cf..147355aed1 100644
--- a/samples/VirtualizationTest/VirtualizationTest.csproj
+++ b/samples/VirtualizationTest/VirtualizationTest.csproj
@@ -147,7 +147,6 @@
-
\ No newline at end of file
diff --git a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj
index e0fc79faea..4271d05f91 100644
--- a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj
+++ b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj
@@ -28,6 +28,5 @@
-
\ No newline at end of file
diff --git a/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj b/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj
index b9fa2f208b..5aa2cd67ba 100644
--- a/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj
+++ b/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj
@@ -28,6 +28,7 @@
+
\ No newline at end of file
diff --git a/src/Avalonia.Logging.Serilog/SerilogExtensions.cs b/src/Avalonia.Logging.Serilog/SerilogExtensions.cs
new file mode 100644
index 0000000000..6abc7e4684
--- /dev/null
+++ b/src/Avalonia.Logging.Serilog/SerilogExtensions.cs
@@ -0,0 +1,51 @@
+using System;
+using Avalonia.Controls;
+using Serilog;
+using SerilogLevel = Serilog.Events.LogEventLevel;
+
+namespace Avalonia.Logging.Serilog
+{
+ ///
+ /// Extension methods for Serilog logging.
+ ///
+ public static class SerilogExtensions
+ {
+ ///
+ /// 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)
+ .WriteTo.Debug(outputTemplate: "{Area}: {Message}")
+ .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)
+ .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
+ .CreateLogger());
+ return builder;
+ }
+ }
+}