diff --git a/Perspex.sln b/Perspex.sln
index bc7e0560af..27866e90c9 100644
--- a/Perspex.sln
+++ b/Perspex.sln
@@ -142,6 +142,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.UnitTests", "tests\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Benchmarks", "tests\Perspex.Benchmarks\Perspex.Benchmarks.csproj", "{410AC439-81A1-4EB5-B5E9-6A7FC6B77F4B}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Logging.Serilog", "src\Perspex.Logging.Serilog\Perspex.Logging.Serilog.csproj", "{B61B66A3-B82D-4875-8001-89D3394FE0C9}"
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Shared\RenderHelpers\RenderHelpers.projitems*{fb05ac90-89ba-4f2f-a924-f37875fb547c}*SharedItemsImports = 4
@@ -150,20 +152,20 @@ Global
src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13
src\Skia\Perspex.Skia\Perspex.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{db070a10-bf39-4752-8456-86e9d5928478}*SharedItemsImports = 4
- src\Shared\RenderHelpers\RenderHelpers.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4
src\Skia\Perspex.Skia\Perspex.Skia.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4
+ src\Shared\RenderHelpers\RenderHelpers.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{78345174-5b52-4a14-b9fd-d5f2428137f0}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{54f237d5-a70a-4752-9656-0c70b1a7b047}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{ff69b927-c545-49ae-8e16-3d14d621aa12}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{811a76cf-1cf6-440f-963b-bbe31bd72a82}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 4
- src\Shared\RenderHelpers\RenderHelpers.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4
src\Skia\Perspex.Skia\Perspex.Skia.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4
+ src\Shared\RenderHelpers\RenderHelpers.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{8c923867-8a8f-4f6b-8b80-47d9e8436166}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{e3a1060b-50d0-44e8-88b6-f44ef2e5bd72}*SharedItemsImports = 4
- src\Shared\RenderHelpers\RenderHelpers.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4
src\Skia\Perspex.Skia\Perspex.Skia.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4
+ src\Shared\RenderHelpers\RenderHelpers.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{e1aa3dbf-9056-4530-9376-18119a7a3ffe}*SharedItemsImports = 4
EndGlobalSection
@@ -1321,6 +1323,30 @@ 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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/samples/ControlCatalog/App.xaml.cs b/samples/ControlCatalog/App.xaml.cs
index ac9f563c8c..2930fa746a 100644
--- a/samples/ControlCatalog/App.xaml.cs
+++ b/samples/ControlCatalog/App.xaml.cs
@@ -4,6 +4,7 @@ using Perspex;
using Perspex.Controls;
using Perspex.Diagnostics;
using Perspex.Markup.Xaml;
+using Perspex.Logging.Serilog;
using Serilog;
namespace ControlCatalog
@@ -41,10 +42,10 @@ namespace ControlCatalog
private void InitializeLogging()
{
#if DEBUG
- Log.Logger = new LoggerConfiguration()
- .MinimumLevel.Error()
- .WriteTo.Trace(outputTemplate: "{Message}")
- .CreateLogger();
+ SerilogLogger.Initialize(new LoggerConfiguration()
+ .MinimumLevel.Warning()
+ .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
+ .CreateLogger());
#endif
}
diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj
index 18c7690b07..ed4b3936ed 100644
--- a/samples/ControlCatalog/ControlCatalog.csproj
+++ b/samples/ControlCatalog/ControlCatalog.csproj
@@ -174,6 +174,10 @@
{42472427-4774-4c81-8aff-9f27b8e31721}
Perspex.Layout
+
+ {b61b66a3-b82d-4875-8001-89d3394fe0c9}
+ Perspex.Logging.Serilog
+
{6417b24e-49c2-4985-8db2-3ab9d898ec91}
Perspex.ReactiveUI
diff --git a/samples/TestApplication/App.config b/samples/TestApplication/App.config
index 92abc44714..6bcf42cd00 100644
--- a/samples/TestApplication/App.config
+++ b/samples/TestApplication/App.config
@@ -18,16 +18,16 @@
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj b/src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj
index f59483a22e..39a869035a 100644
--- a/src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj
+++ b/src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj
@@ -317,10 +317,6 @@
-
- ..\..\..\packages\Serilog.1.5.14\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+MonoTouch10\Serilog.dll
- True
-
..\..\..\packages\Sprache.2.0.0.50\lib\portable-net4+netcore45+win8+wp8+sl5+MonoAndroid+Xamarin.iOS10+MonoTouch\Sprache.dll
True
diff --git a/src/Markup/Perspex.Markup.Xaml/packages.config b/src/Markup/Perspex.Markup.Xaml/packages.config
index f677561e8d..ad16525572 100644
--- a/src/Markup/Perspex.Markup.Xaml/packages.config
+++ b/src/Markup/Perspex.Markup.Xaml/packages.config
@@ -5,6 +5,5 @@
-
\ No newline at end of file
diff --git a/src/Perspex.Base/Logging/ILogSink.cs b/src/Perspex.Base/Logging/ILogSink.cs
new file mode 100644
index 0000000000..b8d1540981
--- /dev/null
+++ b/src/Perspex.Base/Logging/ILogSink.cs
@@ -0,0 +1,15 @@
+// Copyright (c) The Perspex Project. All rights reserved.
+// Licensed under the MIT license. See licence.md file in the project root for full license information.
+
+namespace Perspex.Logging
+{
+ public interface ILogSink
+ {
+ void Log(
+ LogEventLevel level,
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues);
+ }
+}
diff --git a/src/Perspex.Base/Logging/LogArea.cs b/src/Perspex.Base/Logging/LogArea.cs
new file mode 100644
index 0000000000..cf9ac4b331
--- /dev/null
+++ b/src/Perspex.Base/Logging/LogArea.cs
@@ -0,0 +1,31 @@
+// Copyright (c) The Perspex Project. All rights reserved.
+// Licensed under the MIT license. See licence.md file in the project root for full license information.
+
+namespace Perspex.Logging
+{
+ ///
+ /// Specifies the area in which a log event occurred.
+ ///
+ public static class LogArea
+ {
+ ///
+ /// The log event comes from the property and binding system.
+ ///
+ public const string Property = "Property";
+
+ ///
+ /// The log event comes from the visual system.
+ ///
+ public const string Visual = "Visual";
+
+ ///
+ /// The log event comes from the layout system.
+ ///
+ public const string Layout = "Layout";
+
+ ///
+ /// The log event comes from the control system.
+ ///
+ public const string Control = "Control";
+ }
+}
diff --git a/src/Perspex.Base/Logging/LogEventLevel.cs b/src/Perspex.Base/Logging/LogEventLevel.cs
new file mode 100644
index 0000000000..a49b192b16
--- /dev/null
+++ b/src/Perspex.Base/Logging/LogEventLevel.cs
@@ -0,0 +1,41 @@
+// Copyright (c) The Perspex Project. All rights reserved.
+// Licensed under the MIT license. See licence.md file in the project root for full license information.
+
+namespace Perspex.Logging
+{
+ ///
+ /// Specifies the meaning and relative importance of a log event.
+ ///
+ public enum LogEventLevel
+ {
+ ///
+ /// Anything and everything you might want to know about a running block of code.
+ ///
+ Verbose,
+
+ ///
+ /// Internal system events that aren't necessarily observable from the outside.
+ ///
+ Debug,
+
+ ///
+ /// The lifeblood of operational intelligence - things happen.
+ ///
+ Information,
+
+ ///
+ /// Service is degraded or endangered.
+ ///
+ Warning,
+
+ ///
+ /// Functionality is unavailable, invariants are broken or data is lost.
+ ///
+ Error,
+
+ ///
+ /// If you have a pager, it goes off when one of these occurs.
+ ///
+ Fatal
+ }
+}
diff --git a/src/Perspex.Base/Logging/Logger.cs b/src/Perspex.Base/Logging/Logger.cs
new file mode 100644
index 0000000000..311dc55fc0
--- /dev/null
+++ b/src/Perspex.Base/Logging/Logger.cs
@@ -0,0 +1,84 @@
+// Copyright (c) The Perspex Project. All rights reserved.
+// Licensed under the MIT license. See licence.md file in the project root for full license information.
+
+using System;
+using System.Runtime.CompilerServices;
+
+namespace Perspex.Logging
+{
+ public static class Logger
+ {
+ public static ILogSink Sink { get; set; }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Log(
+ LogEventLevel level,
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues)
+ {
+ Sink?.Log(level, area, source, messageTemplate, propertyValues);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Verbose(
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues)
+ {
+ Log(LogEventLevel.Verbose, area, source, messageTemplate, propertyValues);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Debug(
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues)
+ {
+ Log(LogEventLevel.Debug, area, source, messageTemplate, propertyValues);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Information(
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues)
+ {
+ Log(LogEventLevel.Information, area, source, messageTemplate, propertyValues);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Warning(
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues)
+ {
+ Log(LogEventLevel.Warning, area, source, messageTemplate, propertyValues);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Error(
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues)
+ {
+ Log(LogEventLevel.Error, area, source, messageTemplate, propertyValues);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Fatal(
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues)
+ {
+ Log(LogEventLevel.Fatal, area, source, messageTemplate, propertyValues);
+ }
+ }
+}
diff --git a/src/Perspex.Base/Perspex.Base.csproj b/src/Perspex.Base/Perspex.Base.csproj
index 970a8f2b99..ae185b3abf 100644
--- a/src/Perspex.Base/Perspex.Base.csproj
+++ b/src/Perspex.Base/Perspex.Base.csproj
@@ -61,6 +61,10 @@
+
+
+
+
@@ -118,10 +122,6 @@
..\..\packages\JetBrains.Annotations.10.0.0\lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\JetBrains.Annotations.PCL328.dll
True
-
- ..\..\packages\Serilog.1.5.14\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+MonoTouch10\Serilog.dll
- True
-
..\..\packages\Rx-Core.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Core.dll
diff --git a/src/Perspex.Base/PerspexObject.cs b/src/Perspex.Base/PerspexObject.cs
index 37ddf671e2..32f8eedc91 100644
--- a/src/Perspex.Base/PerspexObject.cs
+++ b/src/Perspex.Base/PerspexObject.cs
@@ -7,13 +7,11 @@ using System.ComponentModel;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
-using System.Reactive.Subjects;
using Perspex.Data;
using Perspex.Diagnostics;
+using Perspex.Logging;
using Perspex.Threading;
using Perspex.Utilities;
-using Serilog;
-using Serilog.Core.Enrichers;
namespace Perspex
{
@@ -57,23 +55,11 @@ namespace Perspex
///
private EventHandler _propertyChanged;
- ///
- /// A serilog logger for logging property events.
- ///
- private readonly ILogger _propertyLog;
-
///
/// Initializes a new instance of the class.
///
public PerspexObject()
{
- _propertyLog = Log.ForContext(new[]
- {
- new PropertyEnricher("Area", "Property"),
- new PropertyEnricher("SourceContext", GetType()),
- new PropertyEnricher("Id", GetHashCode()),
- });
-
foreach (var property in PerspexPropertyRegistry.Instance.GetRegistered(this))
{
object value = property.IsDirect ?
@@ -407,9 +393,11 @@ namespace Perspex
throw new ArgumentException($"The property {property.Name} is readonly.");
}
- _propertyLog.Verbose(
- "Bound {Property} to {Binding} with priority LocalValue",
- property,
+ Logger.Verbose(
+ LogArea.Property,
+ this,
+ "Bound {Property} to {Binding} with priority LocalValue",
+ property,
GetDescription(source));
IDisposable subscription = null;
@@ -442,7 +430,9 @@ namespace Perspex
_values.Add(property, v);
}
- _propertyLog.Verbose(
+ Logger.Verbose(
+ LogArea.Property,
+ this,
"Bound {Property} to {Binding} with priority {Priority}",
property,
GetDescription(source),
@@ -613,10 +603,10 @@ namespace Perspex
}
PriorityValue result = new PriorityValue(
+ this,
property.Name,
property.PropertyType,
- validate2,
- _propertyLog);
+ validate2);
result.Changed.Subscribe(x =>
{
@@ -631,11 +621,13 @@ namespace Perspex
{
RaisePropertyChanged(property, oldValue, newValue, (BindingPriority)result.ValuePriority);
- _propertyLog.Verbose(
+ Logger.Verbose(
+ LogArea.Property,
+ this,
"{Property} changed from {$Old} to {$Value} with priority {Priority}",
- property,
- oldValue,
- newValue,
+ property,
+ oldValue,
+ newValue,
(BindingPriority)result.ValuePriority);
}
});
@@ -728,7 +720,9 @@ namespace Perspex
/// The priority.
private void LogPropertySet(PerspexProperty property, object value, BindingPriority priority)
{
- _propertyLog.Verbose(
+ Logger.Verbose(
+ LogArea.Property,
+ this,
"Set {Property} to {$Value} with priority {Priority}",
property,
value,
diff --git a/src/Perspex.Base/PriorityValue.cs b/src/Perspex.Base/PriorityValue.cs
index b68fae1869..a8b72a376d 100644
--- a/src/Perspex.Base/PriorityValue.cs
+++ b/src/Perspex.Base/PriorityValue.cs
@@ -6,8 +6,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Reactive.Subjects;
using System.Text;
+using Perspex.Logging;
using Perspex.Utilities;
-using Serilog;
namespace Perspex
{
@@ -25,6 +25,11 @@ namespace Perspex
///
internal class PriorityValue
{
+ ///
+ /// The owner of the object.
+ ///
+ private readonly PerspexObject _owner;
+
///
/// The name of the property.
///
@@ -55,30 +60,25 @@ namespace Perspex
///
private readonly Func
-
- ..\..\packages\Serilog.1.5.14\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+MonoTouch10\Serilog.dll
- True
-
..\..\packages\Rx-Core.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Core.dll
diff --git a/src/Perspex.Layout/packages.config b/src/Perspex.Layout/packages.config
index c1c997f8a7..d5af0dcd81 100644
--- a/src/Perspex.Layout/packages.config
+++ b/src/Perspex.Layout/packages.config
@@ -5,5 +5,4 @@
-
\ No newline at end of file
diff --git a/src/Perspex.Logging.Serilog/Perspex.Logging.Serilog.csproj b/src/Perspex.Logging.Serilog/Perspex.Logging.Serilog.csproj
new file mode 100644
index 0000000000..1baabb9665
--- /dev/null
+++ b/src/Perspex.Logging.Serilog/Perspex.Logging.Serilog.csproj
@@ -0,0 +1,63 @@
+
+
+
+
+ 10.0
+ Debug
+ AnyCPU
+ {B61B66A3-B82D-4875-8001-89D3394FE0C9}
+ Library
+ Properties
+ Perspex.Logging.Serilog
+ Perspex.Logging.Serilog
+ en-US
+ 512
+ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Profile7
+ v4.5
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+ ..\..\packages\Serilog.1.5.14\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+MonoTouch10\Serilog.dll
+ True
+
+
+
+
+
+
+
+ {b09b78d8-9b26-48b0-9149-d64a2f120f3f}
+ Perspex.Base
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Perspex.Logging.Serilog/Properties/AssemblyInfo.cs b/src/Perspex.Logging.Serilog/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..91c95c4982
--- /dev/null
+++ b/src/Perspex.Logging.Serilog/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Perspex.Serilog")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Perspex.Serilog")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/Perspex.Logging.Serilog/SerilogLogger.cs b/src/Perspex.Logging.Serilog/SerilogLogger.cs
new file mode 100644
index 0000000000..beb5989d55
--- /dev/null
+++ b/src/Perspex.Logging.Serilog/SerilogLogger.cs
@@ -0,0 +1,44 @@
+// Copyright (c) The Perspex Project. All rights reserved.
+// Licensed under the MIT license. See licence.md file in the project root for full license information.
+
+using System.Collections.Generic;
+using Serilog;
+using PerspexLogEventLevel = Perspex.Logging.LogEventLevel;
+using SerilogLogEventLevel = Serilog.Events.LogEventLevel;
+
+namespace Perspex.Logging.Serilog
+{
+ public class SerilogLogger : ILogSink
+ {
+ private readonly ILogger _output;
+ private readonly Dictionary _areas = new Dictionary();
+
+ public SerilogLogger(ILogger output)
+ {
+ _output = output;
+ }
+
+ public static void Initialize(ILogger output)
+ {
+ Logger.Sink = new SerilogLogger(output);
+ }
+
+ public void Log(
+ PerspexLogEventLevel level,
+ string area,
+ object source,
+ string messageTemplate,
+ params object[] propertyValues)
+ {
+ ILogger areaLogger;
+
+ if (!_areas.TryGetValue(area, out areaLogger))
+ {
+ areaLogger = _output.ForContext("Area", area);
+ _areas.Add(area, areaLogger);
+ }
+
+ areaLogger.Write((SerilogLogEventLevel)level, messageTemplate, propertyValues);
+ }
+ }
+}
diff --git a/src/Perspex.Logging.Serilog/packages.config b/src/Perspex.Logging.Serilog/packages.config
new file mode 100644
index 0000000000..dbc72b5331
--- /dev/null
+++ b/src/Perspex.Logging.Serilog/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj b/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj
index be199ab423..819ee3376e 100644
--- a/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj
+++ b/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj
@@ -140,10 +140,6 @@
-
- ..\..\packages\Serilog.1.5.14\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+MonoTouch10\Serilog.dll
- True
-
..\..\packages\Rx-Core.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Core.dll
diff --git a/src/Perspex.SceneGraph/Visual.cs b/src/Perspex.SceneGraph/Visual.cs
index d5570711dc..66f92aa920 100644
--- a/src/Perspex.SceneGraph/Visual.cs
+++ b/src/Perspex.SceneGraph/Visual.cs
@@ -2,19 +2,17 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
-using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Reactive.Linq;
using Perspex.Animation;
using Perspex.Collections;
using Perspex.Data;
+using Perspex.Logging;
using Perspex.Media;
using Perspex.Platform;
using Perspex.Rendering;
using Perspex.VisualTree;
-using Serilog;
-using Serilog.Core.Enrichers;
namespace Perspex
{
@@ -79,7 +77,6 @@ namespace Perspex
private Rect _bounds;
private IVisual _visualParent;
- private readonly ILogger _visualLogger;
///
/// Initializes static members of the class.
@@ -95,13 +92,6 @@ namespace Perspex
///
public Visual()
{
- _visualLogger = Log.ForContext(new[]
- {
- new PropertyEnricher("Area", "Visual"),
- new PropertyEnricher("SourceContext", GetType()),
- new PropertyEnricher("Id", GetHashCode()),
- });
-
var visualChildren = new PerspexList();
visualChildren.ResetBehavior = ResetBehavior.Remove;
visualChildren.Validate = ValidateLogicalChild;
@@ -474,7 +464,7 @@ namespace Perspex
/// The event args.
private void NotifyAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
- _visualLogger.Verbose("Attached to visual tree");
+ Logger.Verbose(LogArea.Visual, this, "Attached to visual tree");
VisualRoot = e.Root;
OnAttachedToVisualTree(e);
@@ -495,7 +485,7 @@ namespace Perspex
/// The event args.
private void NotifyDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
{
- _visualLogger.Verbose("Detached from visual tree");
+ Logger.Verbose(LogArea.Visual, this, "Detached from visual tree");
VisualRoot = null;
OnDetachedFromVisualTree(e);
diff --git a/src/Perspex.SceneGraph/VisualExtensions.cs b/src/Perspex.SceneGraph/VisualExtensions.cs
index cb6362b7af..3228fa4b81 100644
--- a/src/Perspex.SceneGraph/VisualExtensions.cs
+++ b/src/Perspex.SceneGraph/VisualExtensions.cs
@@ -13,8 +13,6 @@ using Perspex.Media;
using Perspex.Platform;
using Perspex.Rendering;
using Perspex.VisualTree;
-using Serilog;
-using Serilog.Core.Enrichers;
namespace Perspex
{
diff --git a/src/Perspex.SceneGraph/packages.config b/src/Perspex.SceneGraph/packages.config
index c1c997f8a7..d5af0dcd81 100644
--- a/src/Perspex.SceneGraph/packages.config
+++ b/src/Perspex.SceneGraph/packages.config
@@ -5,5 +5,4 @@
-
\ No newline at end of file
diff --git a/tests/Perspex.Base.UnitTests/Perspex.Base.UnitTests.csproj b/tests/Perspex.Base.UnitTests/Perspex.Base.UnitTests.csproj
index da3d2aa9cc..879022611c 100644
--- a/tests/Perspex.Base.UnitTests/Perspex.Base.UnitTests.csproj
+++ b/tests/Perspex.Base.UnitTests/Perspex.Base.UnitTests.csproj
@@ -44,14 +44,6 @@
True
-
- ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll
- True
-
-
- ..\..\packages\Serilog.1.5.14\lib\net45\Serilog.FullNetFx.dll
- True
-
..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll
diff --git a/tests/Perspex.Base.UnitTests/PriorityValueTests.cs b/tests/Perspex.Base.UnitTests/PriorityValueTests.cs
index e4cfa408f7..5894ea12c3 100644
--- a/tests/Perspex.Base.UnitTests/PriorityValueTests.cs
+++ b/tests/Perspex.Base.UnitTests/PriorityValueTests.cs
@@ -14,7 +14,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Initial_Value_Should_Be_UnsetValue()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
Assert.Same(PerspexProperty.UnsetValue, target.Value);
}
@@ -22,7 +22,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void First_Binding_Sets_Value()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
target.Add(Single("foo"), 0);
@@ -32,7 +32,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Changing_Binding_Should_Set_Value()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var subject = new BehaviorSubject("foo");
target.Add(subject, 0);
@@ -44,7 +44,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Setting_Direct_Value_Should_Override_Binding()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
target.Add(Single("foo"), 0);
target.SetValue("bar", 0);
@@ -55,7 +55,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Binding_Firing_Should_Override_Direct_Value()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var source = new BehaviorSubject("initial");
target.Add(source, 0);
@@ -69,7 +69,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Earlier_Binding_Firing_Should_Override_Later_Priority_0()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var nonActive = new BehaviorSubject("na");
var source = new BehaviorSubject("initial");
@@ -85,7 +85,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Earlier_Binding_Firing_Should_Not_Override_Later_Priority_1()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var nonActive = new BehaviorSubject("na");
var source = new BehaviorSubject("initial");
@@ -101,7 +101,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Binding_Completing_Should_Revert_To_Direct_Value()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var source = new BehaviorSubject("initial");
target.Add(source, 0);
@@ -117,7 +117,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Binding_With_Lower_Priority_Has_Precedence()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
target.Add(Single("foo"), 1);
target.Add(Single("bar"), 0);
@@ -129,7 +129,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Later_Binding_With_Same_Priority_Should_Take_Precedence()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
target.Add(Single("foo"), 1);
target.Add(Single("bar"), 0);
@@ -142,7 +142,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Changing_Binding_With_Lower_Priority_Should_Set_Not_Value()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var subject = new BehaviorSubject("bar");
target.Add(Single("foo"), 0);
@@ -155,7 +155,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void UnsetValue_Should_Fall_Back_To_Next_Binding()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var subject = new BehaviorSubject("bar");
target.Add(subject, 0);
@@ -171,7 +171,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Adding_Value_Should_Call_OnNext()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
bool called = false;
target.Changed.Subscribe(value => called = value.Item1 == PerspexProperty.UnsetValue && (string)value.Item2 == "foo");
@@ -183,7 +183,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Changing_Value_Should_Call_OnNext()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var subject = new BehaviorSubject("foo");
bool called = false;
@@ -197,7 +197,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Disposing_A_Binding_Should_Revert_To_Next_Value()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
target.Add(Single("foo"), 0);
var disposable = target.Add(Single("bar"), 0);
@@ -210,7 +210,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Disposing_A_Binding_Should_Remove_BindingEntry()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
target.Add(Single("foo"), 0);
var disposable = target.Add(Single("bar"), 0);
@@ -223,7 +223,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Completing_A_Binding_Should_Revert_To_Previous_Binding()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var source = new BehaviorSubject("bar");
target.Add(Single("foo"), 0);
@@ -237,7 +237,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Completing_A_Binding_Should_Revert_To_Lower_Priority()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var source = new BehaviorSubject("bar");
target.Add(Single("foo"), 1);
@@ -251,7 +251,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Completing_A_Binding_Should_Remove_BindingEntry()
{
- var target = new PriorityValue("Test", typeof(string));
+ var target = new PriorityValue(null, "Test", typeof(string));
var subject = new BehaviorSubject("bar");
target.Add(Single("foo"), 0);
@@ -265,7 +265,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Direct_Value_Should_Be_Coerced()
{
- var target = new PriorityValue("Test", typeof(int), x => Math.Min((int)x, 10));
+ var target = new PriorityValue(null, "Test", typeof(int), x => Math.Min((int)x, 10));
target.SetValue(5, 0);
Assert.Equal(5, target.Value);
@@ -276,7 +276,7 @@ namespace Perspex.Base.UnitTests
[Fact]
public void Bound_Value_Should_Be_Coerced()
{
- var target = new PriorityValue("Test", typeof(int), x => Math.Min((int)x, 10));
+ var target = new PriorityValue(null, "Test", typeof(int), x => Math.Min((int)x, 10));
var source = new Subject();
target.Add(source, 0);
@@ -290,7 +290,7 @@ namespace Perspex.Base.UnitTests
public void Revalidate_Should_ReCoerce_Value()
{
var max = 10;
- var target = new PriorityValue("Test", typeof(int), x => Math.Min((int)x, max));
+ var target = new PriorityValue(null, "Test", typeof(int), x => Math.Min((int)x, max));
var source = new Subject();
target.Add(source, 0);
diff --git a/tests/Perspex.Base.UnitTests/packages.config b/tests/Perspex.Base.UnitTests/packages.config
index 164dada787..be674ecc80 100644
--- a/tests/Perspex.Base.UnitTests/packages.config
+++ b/tests/Perspex.Base.UnitTests/packages.config
@@ -6,7 +6,6 @@
-
diff --git a/tests/Perspex.RenderTests/app.config b/tests/Perspex.RenderTests/app.config
index 6d348f8066..7940b2ce88 100644
--- a/tests/Perspex.RenderTests/app.config
+++ b/tests/Perspex.RenderTests/app.config
@@ -15,16 +15,16 @@
-
-
+
+
-
-
+
+
-
-
+
+