From 7dc125d4c0288facffa7f20847bdb1f5e9cb7d75 Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 26 Jan 2015 00:51:58 +0000 Subject: [PATCH 01/10] #357 PeriodicBatchingSink now flushes on unhandled exceptions --- .../Sinks/PeriodicBatching/PeriodicBatchingSink.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs index 13818a08b..479e5fe49 100644 --- a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs +++ b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs @@ -60,13 +60,23 @@ protected PeriodicBatchingSink(int batchSizeLimit, TimeSpan period) AppDomain.CurrentDomain.DomainUnload += OnAppDomainUnloading; AppDomain.CurrentDomain.ProcessExit += OnAppDomainUnloading; + AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnloading; } void OnAppDomainUnloading(object sender, EventArgs args) { + if (ComeFromInvalidAppDomainContext(args)) + return; + CloseAndFlush(); } + static bool ComeFromInvalidAppDomainContext(EventArgs args) + { + var eventArgs = args as UnhandledExceptionEventArgs; + return eventArgs == null || !eventArgs.IsTerminating; + } + void CloseAndFlush() { lock (_stateLock) @@ -79,6 +89,7 @@ void CloseAndFlush() AppDomain.CurrentDomain.DomainUnload -= OnAppDomainUnloading; AppDomain.CurrentDomain.ProcessExit -= OnAppDomainUnloading; + AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnloading; var wh = new ManualResetEvent(false); if (_timer.Dispose(wh)) From 3fa70991ffcd9acfe76005e83f738dbb76a56993 Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 16 Feb 2015 22:21:53 +0000 Subject: [PATCH 02/10] Inlining method --- .../Sinks/PeriodicBatching/PeriodicBatchingSink.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs index 479e5fe49..09eab820c 100644 --- a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs +++ b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs @@ -65,18 +65,13 @@ protected PeriodicBatchingSink(int batchSizeLimit, TimeSpan period) void OnAppDomainUnloading(object sender, EventArgs args) { - if (ComeFromInvalidAppDomainContext(args)) + var eventArgs = args as UnhandledExceptionEventArgs; + if (eventArgs != null && !eventArgs.IsTerminating) return; CloseAndFlush(); } - static bool ComeFromInvalidAppDomainContext(EventArgs args) - { - var eventArgs = args as UnhandledExceptionEventArgs; - return eventArgs == null || !eventArgs.IsTerminating; - } - void CloseAndFlush() { lock (_stateLock) From 103ce9c4e6d7ca298f2c751b675f15595b306742 Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 17 Feb 2015 21:54:26 +0000 Subject: [PATCH 03/10] Fixing event unsubscription --- .../Sinks/PeriodicBatching/PeriodicBatchingSink.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs index 09eab820c..397fc63f4 100644 --- a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs +++ b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink.cs @@ -84,7 +84,7 @@ void CloseAndFlush() AppDomain.CurrentDomain.DomainUnload -= OnAppDomainUnloading; AppDomain.CurrentDomain.ProcessExit -= OnAppDomainUnloading; - AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnloading; + AppDomain.CurrentDomain.UnhandledException -= OnAppDomainUnloading; var wh = new ManualResetEvent(false); if (_timer.Dispose(wh)) From b34714c8b167cb9345b7f6ee9f95c203f1252d9e Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 17 Feb 2015 22:00:14 +0000 Subject: [PATCH 04/10] Updating PeriodicBatchingSink-net40 as well --- .../Sinks/PeriodicBatching/PeriodicBatchingSink-net40.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink-net40.cs b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink-net40.cs index dc9fc8c0b..57f85a4c5 100644 --- a/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink-net40.cs +++ b/src/Serilog.FullNetFx/Sinks/PeriodicBatching/PeriodicBatchingSink-net40.cs @@ -58,10 +58,15 @@ protected PeriodicBatchingSink(int batchSizeLimit, TimeSpan period) AppDomain.CurrentDomain.DomainUnload += OnAppDomainUnloading; AppDomain.CurrentDomain.ProcessExit += OnAppDomainUnloading; + AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnloading; } void OnAppDomainUnloading(object sender, EventArgs args) { + var eventArgs = args as UnhandledExceptionEventArgs; + if (eventArgs != null && !eventArgs.IsTerminating) + return; + CloseAndFlush(); } @@ -77,6 +82,7 @@ void CloseAndFlush() AppDomain.CurrentDomain.DomainUnload -= OnAppDomainUnloading; AppDomain.CurrentDomain.ProcessExit -= OnAppDomainUnloading; + AppDomain.CurrentDomain.UnhandledException -= OnAppDomainUnloading; var wh = new ManualResetEvent(false); if (_timer.Dispose(wh)) From 48c48f29e28c417fe0ff3fce7369ffda52f44105 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Wed, 25 Mar 2015 17:27:30 +1000 Subject: [PATCH 05/10] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index f5efb416c..7168c7243 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,4 @@ Serilog combines the best features of traditional and structured diagnostic logg Would you like to help make Serilog even better? We keep a list of issues that are approachable for newcomers under the [up-for-grabs](https://github.com/serilog/serilog/issues?labels=up-for-grabs&state=open) label! -Copyright © 2014 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html). - -Needle and thread logo a derivative of work by [Kenneth Appiah](http://thenounproject.com/kenset/). +Copyright © 2014 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html). Needle and thread logo a derivative of work by [Kenneth Appiah](http://www.kensets.com/). From 86cae4f925e036ef5f47fe7f249212cf05dcd4b6 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Sun, 29 Mar 2015 12:51:02 +1000 Subject: [PATCH 06/10] Removes Serilog.Extras.Topshelf - the Topshelf project now includes this functionality (and is maintaining it more actively) so we'll publish a redirect package to it once it's on NuGet. https://github.com/Topshelf/Topshelf/issues/227 --- Serilog-net40.sln | 6 - Serilog.sln | 7 - .../Extras/Topshelf/MessageProvider.cs | 38 ---- .../SerilogConfigurationExtensions.cs | 45 ---- .../Topshelf/SerilogHostLoggerConfigurator.cs | 49 ----- .../Extras/Topshelf/SerilogWriter.cs | 205 ------------------ .../Extras/Topshelf/SerilogWriterFactory.cs | 49 ----- .../Properties/AssemblyInfo.cs | 12 - .../Serilog.Extras.Topshelf-net40.csproj | 84 ------- .../Serilog.Extras.Topshelf.csproj | 79 ------- .../Serilog.Extras.Topshelf.nuspec | 23 -- src/Serilog.Extras.Topshelf/packages.config | 4 - 12 files changed, 601 deletions(-) delete mode 100644 src/Serilog.Extras.Topshelf/Extras/Topshelf/MessageProvider.cs delete mode 100644 src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogConfigurationExtensions.cs delete mode 100644 src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogHostLoggerConfigurator.cs delete mode 100644 src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogWriter.cs delete mode 100644 src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogWriterFactory.cs delete mode 100644 src/Serilog.Extras.Topshelf/Properties/AssemblyInfo.cs delete mode 100644 src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf-net40.csproj delete mode 100644 src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf.csproj delete mode 100644 src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf.nuspec delete mode 100644 src/Serilog.Extras.Topshelf/packages.config diff --git a/Serilog-net40.sln b/Serilog-net40.sln index b3149c7c0..3f67c8365 100644 --- a/Serilog-net40.sln +++ b/Serilog-net40.sln @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.FullNetFx-net40", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Tests-net40", "test\Serilog.Tests\Serilog.Tests-net40.csproj", "{D5648551-D19D-41E3-9FC1-E74B111EEF41}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.Topshelf-net40", "src\Serilog.Extras.Topshelf\Serilog.Extras.Topshelf-net40.csproj", "{52B596D5-5B55-4E8B-86F7-037CCA22AEC5}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,10 +27,6 @@ Global {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5648551-D19D-41E3-9FC1-E74B111EEF41}.Release|Any CPU.Build.0 = Release|Any CPU - {52B596D5-5B55-4E8B-86F7-037CCA22AEC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52B596D5-5B55-4E8B-86F7-037CCA22AEC5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52B596D5-5B55-4E8B-86F7-037CCA22AEC5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52B596D5-5B55-4E8B-86F7-037CCA22AEC5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Serilog.sln b/Serilog.sln index 55ff0ae9c..513bd86a1 100644 --- a/Serilog.sln +++ b/Serilog.sln @@ -24,8 +24,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.FullNetFx", "src\Se EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.PerformanceTests", "test\Serilog.PerformanceTests\Serilog.PerformanceTests.csproj", "{6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.Topshelf", "src\Serilog.Extras.TopShelf\Serilog.Extras.Topshelf.csproj", "{1C0FE823-FCCB-46B4-B76C-9661295A312A}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.Web", "src\Serilog.Extras.Web\Serilog.Extras.Web.csproj", "{13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.AppSettings", "src\Serilog.Extras.AppSettings\Serilog.Extras.AppSettings.csproj", "{21CAF132-BBAB-41FD-A018-EB9AE54822ED}" @@ -72,10 +70,6 @@ Global {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Release|Any CPU.Build.0 = Release|Any CPU - {1C0FE823-FCCB-46B4-B76C-9661295A312A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1C0FE823-FCCB-46B4-B76C-9661295A312A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1C0FE823-FCCB-46B4-B76C-9661295A312A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1C0FE823-FCCB-46B4-B76C-9661295A312A}.Release|Any CPU.Build.0 = Release|Any CPU {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}.Debug|Any CPU.Build.0 = Debug|Any CPU {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -133,7 +127,6 @@ Global {D5648551-D19D-41E3-9FC1-E74B111EEF41} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {7A9E1095-167D-402A-B43D-B36B97FF183D} = {037440DE-440B-4129-9F7A-09B42D00397E} {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} - {1C0FE823-FCCB-46B4-B76C-9661295A312A} = {037440DE-440B-4129-9F7A-09B42D00397E} {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD} = {037440DE-440B-4129-9F7A-09B42D00397E} {21CAF132-BBAB-41FD-A018-EB9AE54822ED} = {037440DE-440B-4129-9F7A-09B42D00397E} {FDCEBC10-F403-4DDD-8594-DE6D7DD543AF} = {037440DE-440B-4129-9F7A-09B42D00397E} diff --git a/src/Serilog.Extras.Topshelf/Extras/Topshelf/MessageProvider.cs b/src/Serilog.Extras.Topshelf/Extras/Topshelf/MessageProvider.cs deleted file mode 100644 index e936762b9..000000000 --- a/src/Serilog.Extras.Topshelf/Extras/Topshelf/MessageProvider.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 Serilog Contributors -// Based on Topshelf.Log4Net, copyright 2007-2012 Chris Patterson, -// Dru Sellers, Travis Smith, et. al. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Topshelf.Logging; - -namespace Serilog.Extras.Topshelf -{ - class MessageProvider - { - readonly LogWriterOutputProvider _messageProvider; - object _message; - - public MessageProvider(LogWriterOutputProvider messageProvider) - { - _messageProvider = messageProvider; - } - - public override string ToString() - { - return _messageProvider != null ? - (_message = _message ?? _messageProvider()).ToString() : - ""; - } - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogConfigurationExtensions.cs b/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogConfigurationExtensions.cs deleted file mode 100644 index 6cddc9c53..000000000 --- a/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogConfigurationExtensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2007-2012 Chris Patterson, Dru Sellers, Travis Smith, et. al. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use -// this file except in compliance with the License. You may obtain a copy of the -// License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the -// specific language governing permissions and limitations under the License. - -using System; -using Topshelf.HostConfigurators; -using Topshelf.Logging; - -namespace Serilog.Extras.Topshelf -{ - /// - /// Extensions for configuring Logging for Serilog - /// - public static class SerilogConfigurationExtensions - { - /// - /// Specify that you want to use the Serilog logging engine. - /// - /// - public static void UseSerilog(this HostConfigurator configurator) - { - HostLogger.UseLogger(new SerilogHostLoggerConfigurator()); - } - - /// - /// Specify that you want to use the Serilog logging engine. - /// - /// - /// Serilog logger to use. - public static void UseSerilog(this HostConfigurator configurator, ILogger logger) - { - if (logger == null) throw new ArgumentNullException("logger"); - HostLogger.UseLogger(new SerilogHostLoggerConfigurator(logger)); - } - } -} diff --git a/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogHostLoggerConfigurator.cs b/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogHostLoggerConfigurator.cs deleted file mode 100644 index 55a272c7f..000000000 --- a/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogHostLoggerConfigurator.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 Serilog Contributors -// Based on Topshelf.Log4Net, copyright 2007-2012 Chris Patterson, -// Dru Sellers, Travis Smith, et. al. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Topshelf.Logging; - -namespace Serilog.Extras.Topshelf -{ - /// - /// Configures the Topshelf host to write log messages to Serilog. - /// - public class SerilogHostLoggerConfigurator : HostLoggerConfigurator - { - readonly ILogger _logger; - - /// - /// Construct the host configurator. - /// - /// Optional logger instance for the - /// configurator to use. If this is omitted, the default - /// logger will be used. - public SerilogHostLoggerConfigurator(ILogger logger = null) - { - _logger = logger; - } - - /// - /// Create the factory that the host will use to write - /// messages. - /// - /// The factory. - public LogWriterFactory CreateLogWriterFactory() - { - return new SerilogWriterFactory(_logger); - } - } -} diff --git a/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogWriter.cs b/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogWriter.cs deleted file mode 100644 index 49fcd97ca..000000000 --- a/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogWriter.cs +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2014 Serilog Contributors -// Based on Topshelf.Log4Net, copyright 2007-2012 Chris Patterson, -// Dru Sellers, Travis Smith, et. al. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using Serilog.Events; -using Topshelf.Logging; - -namespace Serilog.Extras.Topshelf -{ - class SerilogWriter : LogWriter - { - readonly ILogger _logger; - const string ObjectMessageTemplate = "{Object}"; - - public SerilogWriter(ILogger logger) - { - if (logger == null) throw new ArgumentNullException("logger"); - _logger = logger; - } - - static LogEventLevel TopshelfToSerilogLevel(LoggingLevel level) - { - if (level == LoggingLevel.All) - return LogEventLevel.Verbose; - if (level == LoggingLevel.Debug) - return LogEventLevel.Debug; - if (level == LoggingLevel.Info) - return LogEventLevel.Information; - if (level == LoggingLevel.Warn) - return LogEventLevel.Warning; - if (level == LoggingLevel.Error) - return LogEventLevel.Error; - return LogEventLevel.Fatal; - } - - public void Log(LoggingLevel level, object obj) - { - _logger.Write(TopshelfToSerilogLevel(level), ObjectMessageTemplate, obj); - } - - public void Log(LoggingLevel level, object obj, Exception exception) - { - _logger.Write(TopshelfToSerilogLevel(level), exception, ObjectMessageTemplate, obj); - } - - public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider) - { - _logger.Write(TopshelfToSerilogLevel(level), ObjectMessageTemplate, new MessageProvider(messageProvider)); - } - - public void LogFormat(LoggingLevel level, IFormatProvider formatProvider, string format, params object[] args) - { - _logger.Write(TopshelfToSerilogLevel(level), format, args); - } - - public void LogFormat(LoggingLevel level, string format, params object[] args) - { - _logger.Write(TopshelfToSerilogLevel(level), format, args); - } - - public void Debug(object obj) - { - _logger.Debug(ObjectMessageTemplate, obj); - } - - public void Debug(object obj, Exception exception) - { - _logger.Debug(exception, ObjectMessageTemplate, obj); - } - - public void Debug(LogWriterOutputProvider messageProvider) - { - _logger.Debug(ObjectMessageTemplate, new MessageProvider(messageProvider)); - } - - public void DebugFormat(IFormatProvider formatProvider, string format, params object[] args) - { - _logger.Debug(format, args); - } - - public void DebugFormat(string format, params object[] args) - { - _logger.Debug(format, args); - } - - public void Info(object obj) - { - _logger.Information(ObjectMessageTemplate, obj); - } - - public void Info(object obj, Exception exception) - { - _logger.Information(exception, ObjectMessageTemplate, obj); - } - - public void Info(LogWriterOutputProvider messageProvider) - { - _logger.Information(ObjectMessageTemplate, new MessageProvider(messageProvider)); - } - - public void InfoFormat(IFormatProvider formatProvider, string format, params object[] args) - { - _logger.Information(format, args); - } - - public void InfoFormat(string format, params object[] args) - { - _logger.Information(format, args); - } - - public void Warn(object obj) - { - _logger.Warning(ObjectMessageTemplate, obj); - } - - public void Warn(object obj, Exception exception) - { - _logger.Warning(exception, ObjectMessageTemplate, obj); - } - - public void Warn(LogWriterOutputProvider messageProvider) - { - _logger.Warning(ObjectMessageTemplate, new MessageProvider(messageProvider)); - } - - public void WarnFormat(IFormatProvider formatProvider, string format, params object[] args) - { - _logger.Warning(format, args); - } - - public void WarnFormat(string format, params object[] args) - { - _logger.Warning(format, args); - } - - public void Error(object obj) - { - _logger.Error(ObjectMessageTemplate, obj); - } - - public void Error(object obj, Exception exception) - { - _logger.Error(exception, ObjectMessageTemplate, obj); - } - - public void Error(LogWriterOutputProvider messageProvider) - { - _logger.Error(ObjectMessageTemplate, new MessageProvider(messageProvider)); - } - - public void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args) - { - _logger.Error(format, args); - } - - public void ErrorFormat(string format, params object[] args) - { - _logger.Error(format, args); - } - - public void Fatal(object obj) - { - _logger.Fatal(ObjectMessageTemplate, obj); - } - - public void Fatal(object obj, Exception exception) - { - _logger.Fatal(exception, ObjectMessageTemplate, obj); - } - - public void Fatal(LogWriterOutputProvider messageProvider) - { - _logger.Fatal(ObjectMessageTemplate, new MessageProvider(messageProvider)); - } - - public void FatalFormat(IFormatProvider formatProvider, string format, params object[] args) - { - _logger.Fatal(format, args); - } - - public void FatalFormat(string format, params object[] args) - { - _logger.Fatal(format, args); - } - - public bool IsDebugEnabled { get { return _logger.IsEnabled(LogEventLevel.Debug); } } - public bool IsInfoEnabled { get { return _logger.IsEnabled(LogEventLevel.Information); } } - public bool IsWarnEnabled { get { return _logger.IsEnabled(LogEventLevel.Warning); } } - public bool IsErrorEnabled { get { return _logger.IsEnabled(LogEventLevel.Error); } } - public bool IsFatalEnabled { get { return _logger.IsEnabled(LogEventLevel.Fatal); } } - } -} diff --git a/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogWriterFactory.cs b/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogWriterFactory.cs deleted file mode 100644 index e2a95d0bc..000000000 --- a/src/Serilog.Extras.Topshelf/Extras/Topshelf/SerilogWriterFactory.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 Serilog Contributors -// Based on Topshelf.Log4Net, copyright 2007-2012 Chris Patterson, -// Dru Sellers, Travis Smith, et. al. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using Serilog.Core; -using Topshelf.Logging; - -namespace Serilog.Extras.Topshelf -{ - class SerilogWriterFactory : LogWriterFactory - { - readonly ILogger _logger; - - public SerilogWriterFactory(ILogger logger = null) - { - _logger = logger; - } - - public LogWriter Get(string name) - { - var contextual = _logger == null ? - Log.ForContext(Constants.SourceContextPropertyName, name) : - _logger.ForContext(Constants.SourceContextPropertyName, name); - - return new SerilogWriter(contextual); - } - - public void Shutdown() - { - var toShutDown = (_logger ?? Log.Logger) as IDisposable; - if (toShutDown != null) - toShutDown.Dispose(); - } - } -} - diff --git a/src/Serilog.Extras.Topshelf/Properties/AssemblyInfo.cs b/src/Serilog.Extras.Topshelf/Properties/AssemblyInfo.cs deleted file mode 100644 index 45efe666d..000000000 --- a/src/Serilog.Extras.Topshelf/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyTitle("Serilog.Extras.Topshelf")] -[assembly: AssemblyDescription("Serilog logging support for the Topshelf Windows service host")] -[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2013")] - -[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" + - "6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" + - "d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" + - "94191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066" + - "b19485ec")] \ No newline at end of file diff --git a/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf-net40.csproj b/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf-net40.csproj deleted file mode 100644 index a30473b0e..000000000 --- a/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf-net40.csproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - - Debug - AnyCPU - {52B596D5-5B55-4E8B-86F7-037CCA22AEC5} - Library - Properties - Serilog.Extras.Topshelf - Serilog.Extras.Topshelf - v4.0 - 512 - - - true - full - false - bin40\Debug\ - DEBUG;TRACE - prompt - 4 - bin40\Debug\Serilog.Extras.Topshelf.xml - - - pdbonly - true - bin40\Release\ - TRACE - prompt - 4 - bin40\Release\Serilog.Extras.Topshelf.xml - - - true - - - ..\..\assets\Serilog.snk - - - - - - - - - - - ..\..\packages\Topshelf.3.1.4\lib\net40-full\Topshelf.dll - - - - - - - - - - - Properties\CommonAssemblyInfo.cs - - - - - Serilog.snk - - - - - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog-net40 - - - - - \ No newline at end of file diff --git a/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf.csproj b/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf.csproj deleted file mode 100644 index 7ddfade75..000000000 --- a/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf.csproj +++ /dev/null @@ -1,79 +0,0 @@ - - - - - Debug - AnyCPU - {1C0FE823-FCCB-46B4-B76C-9661295A312A} - Library - Properties - Serilog - Serilog.Extras.Topshelf - v4.5 - 512 - ..\..\ - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - bin\Debug\Serilog.Extras.Topshelf.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - bin\Release\Serilog.Extras.Topshelf.XML - - - true - - - ..\..\assets\Serilog.snk - - - - - - - False - ..\..\packages\Topshelf.3.1.4\lib\net40-full\Topshelf.dll - - - - - - - Properties\CommonAssemblyInfo.cs - - - - - - - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog - - - - - Serilog.snk - - - - Designer - - - - \ No newline at end of file diff --git a/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf.nuspec b/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf.nuspec deleted file mode 100644 index f03588180..000000000 --- a/src/Serilog.Extras.Topshelf/Serilog.Extras.Topshelf.nuspec +++ /dev/null @@ -1,23 +0,0 @@ - - - - Serilog.Extras.Topshelf - $version$ - Serilog Contributors - Serilog logging support for the Topshelf Windows service host. - en-US - http://serilog.net - http://www.apache.org/licenses/LICENSE-2.0 - http://serilog.net/images/serilog-nuget.png - serilog logging topshelf - - - - - - - - - - - diff --git a/src/Serilog.Extras.Topshelf/packages.config b/src/Serilog.Extras.Topshelf/packages.config deleted file mode 100644 index 6e27d1105..000000000 --- a/src/Serilog.Extras.Topshelf/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 9f3a87a03e5871b7795c6dc1cf809388d36ea9f9 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Sun, 29 Mar 2015 15:28:16 +1000 Subject: [PATCH 07/10] Removed Serilog.Extras.Attributed, now at https://github.com/destructurama/attributed (see #414) --- Serilog.sln | 14 -- .../AttributedDestructuringPolicy.cs | 132 ------------------ .../Extras/Attributed/LogAsScalarAttribute.cs | 47 ------- .../Extras/Attributed/NotLoggedAttribute.cs | 26 ---- ...LoggerConfigurationAttributedExtensions.cs | 35 ----- .../Properties/AssemblyInfo.cs | 5 - .../Serilog.Extras.Attributed.csproj | 83 ----------- .../Serilog.Extras.Attributed.nuspec | 17 --- .../AttributedDestructuringTests.cs | 64 --------- .../Properties/AssemblyInfo.cs | 35 ----- .../Serilog.Extras.Attributed.Tests.csproj | 76 ---------- .../packages.config | 4 - 12 files changed, 538 deletions(-) delete mode 100644 src/Serilog.Extras.Attributed/Extras/Attributed/AttributedDestructuringPolicy.cs delete mode 100644 src/Serilog.Extras.Attributed/Extras/Attributed/LogAsScalarAttribute.cs delete mode 100644 src/Serilog.Extras.Attributed/Extras/Attributed/NotLoggedAttribute.cs delete mode 100644 src/Serilog.Extras.Attributed/LoggerConfigurationAttributedExtensions.cs delete mode 100644 src/Serilog.Extras.Attributed/Properties/AssemblyInfo.cs delete mode 100644 src/Serilog.Extras.Attributed/Serilog.Extras.Attributed.csproj delete mode 100644 src/Serilog.Extras.Attributed/Serilog.Extras.Attributed.nuspec delete mode 100644 test/Serilog.Extras.Attributed.Tests/AttributedDestructuringTests.cs delete mode 100644 test/Serilog.Extras.Attributed.Tests/Properties/AssemblyInfo.cs delete mode 100644 test/Serilog.Extras.Attributed.Tests/Serilog.Extras.Attributed.Tests.csproj delete mode 100644 test/Serilog.Extras.Attributed.Tests/packages.config diff --git a/Serilog.sln b/Serilog.sln index 513bd86a1..6d6497ed1 100644 --- a/Serilog.sln +++ b/Serilog.sln @@ -36,10 +36,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.SmokeTest", "test\S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.AppSettings.Tests", "test\Serilog.Extras.AppSettings.Tests\Serilog.Extras.AppSettings.Tests.csproj", "{67398D2A-0829-4373-ABC5-2161FEB28A05}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.Attributed", "src\Serilog.Extras.Attributed\Serilog.Extras.Attributed.csproj", "{A79F906E-0298-49DC-93EC-CE4F1F5D13E2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.Attributed.Tests", "test\Serilog.Extras.Attributed.Tests\Serilog.Extras.Attributed.Tests.csproj", "{182ECDA3-A97D-4BB6-BC6F-60A137478B92}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.DestructureByIgnoring", "src\Serilog.Extras.DestructureByIgnoring\Serilog.Extras.DestructureByIgnoring.csproj", "{C5CC62F4-310F-495C-96EA-B8E5D26F8D57}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.DestructureByIgnoring.Tests", "test\Serilog.Extras.DestructureByIgnoring.Tests\Serilog.Extras.DestructureByIgnoring.Tests.csproj", "{977E42C3-D501-4730-98FF-525B753B1E3A}" @@ -94,14 +90,6 @@ Global {67398D2A-0829-4373-ABC5-2161FEB28A05}.Debug|Any CPU.Build.0 = Debug|Any CPU {67398D2A-0829-4373-ABC5-2161FEB28A05}.Release|Any CPU.ActiveCfg = Release|Any CPU {67398D2A-0829-4373-ABC5-2161FEB28A05}.Release|Any CPU.Build.0 = Release|Any CPU - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2}.Release|Any CPU.Build.0 = Release|Any CPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92}.Debug|Any CPU.Build.0 = Debug|Any CPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92}.Release|Any CPU.ActiveCfg = Release|Any CPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92}.Release|Any CPU.Build.0 = Release|Any CPU {C5CC62F4-310F-495C-96EA-B8E5D26F8D57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C5CC62F4-310F-495C-96EA-B8E5D26F8D57}.Debug|Any CPU.Build.0 = Debug|Any CPU {C5CC62F4-310F-495C-96EA-B8E5D26F8D57}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -133,8 +121,6 @@ Global {4F81EDAE-2E06-4024-925A-E495C852BDCF} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {58563C46-B781-4799-ABD5-9745F94478FD} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {67398D2A-0829-4373-ABC5-2161FEB28A05} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2} = {037440DE-440B-4129-9F7A-09B42D00397E} - {182ECDA3-A97D-4BB6-BC6F-60A137478B92} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {C5CC62F4-310F-495C-96EA-B8E5D26F8D57} = {037440DE-440B-4129-9F7A-09B42D00397E} {977E42C3-D501-4730-98FF-525B753B1E3A} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {088A4030-7C7A-4434-964A-8E9E42DB17F0} = {037440DE-440B-4129-9F7A-09B42D00397E} diff --git a/src/Serilog.Extras.Attributed/Extras/Attributed/AttributedDestructuringPolicy.cs b/src/Serilog.Extras.Attributed/Extras/Attributed/AttributedDestructuringPolicy.cs deleted file mode 100644 index bd674d957..000000000 --- a/src/Serilog.Extras.Attributed/Extras/Attributed/AttributedDestructuringPolicy.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Serilog.Core; -using Serilog.Debugging; -using Serilog.Events; -using Serilog.Parameters; - -namespace Serilog.Extras.Attributed -{ - class AttributedDestructuringPolicy : IDestructuringPolicy - { - readonly object _cacheLock = new object(); - readonly HashSet _ignored = new HashSet(); - readonly Dictionary> _cache = new Dictionary>(); - - public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventPropertyValue result) - { - var t = value.GetType(); - lock (_cacheLock) - { - if (_ignored.Contains(t)) - { - result = null; - return false; - } - - Func cached; - if (_cache.TryGetValue(t, out cached)) - { - result = cached(value, propertyValueFactory); - return true; - } - } - - var ti = t.GetTypeInfo(); - - var logAsScalar = ti.GetCustomAttribute(); - if (logAsScalar != null) - { - lock (_cacheLock) - _cache[t] = (o, f) => MakeScalar(o, logAsScalar.IsMutable); - - } - else - { - var properties = t.GetPropertiesRecursive() - .ToList(); - if (properties.Any(pi => - pi.GetCustomAttribute() != null || - pi.GetCustomAttribute() != null)) - { - var loggedProperties = properties - .Where(pi => pi.GetCustomAttribute() == null) - .ToList(); - - var scalars = loggedProperties - .Where(pi => pi.GetCustomAttribute() != null) - .ToDictionary(pi => pi, pi => pi.GetCustomAttribute().IsMutable); - - lock (_cacheLock) - _cache[t] = (o, f) => MakeStructure(o, loggedProperties, scalars, f, t); - } - else - { - lock(_cacheLock) - _ignored.Add(t); - } - } - - return TryDestructure(value, propertyValueFactory, out result); - } - - static LogEventPropertyValue MakeStructure(object value, IEnumerable loggedProperties, Dictionary scalars, ILogEventPropertyValueFactory propertyValueFactory, Type type) - { - var structureProperties = new List(); - foreach (var pi in loggedProperties) - { - object propValue; - try - { - propValue = pi.GetValue(value); - } - catch (TargetInvocationException ex) - { - SelfLog.WriteLine("The property accessor {0} threw exception {1}", pi, ex); - propValue = "The property accessor threw an exception: " + ex.InnerException.GetType().Name; - } - - LogEventPropertyValue pv; - bool stringify; - - if (propValue == null) - { - pv = new ScalarValue(null); - } - else if (scalars.TryGetValue(pi, out stringify)) - { - pv = MakeScalar(propValue, stringify); - } - else - { - pv = propertyValueFactory.CreatePropertyValue(propValue, true); - } - - structureProperties.Add(new LogEventProperty(pi.Name, pv)); - } - return new StructureValue(structureProperties, type.Name); - } - - static ScalarValue MakeScalar(object value, bool stringify) - { - return new ScalarValue(stringify ? value.ToString() : value); - } - - } -} diff --git a/src/Serilog.Extras.Attributed/Extras/Attributed/LogAsScalarAttribute.cs b/src/Serilog.Extras.Attributed/Extras/Attributed/LogAsScalarAttribute.cs deleted file mode 100644 index 0c1ec156e..000000000 --- a/src/Serilog.Extras.Attributed/Extras/Attributed/LogAsScalarAttribute.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; - -namespace Serilog.Extras.Attributed -{ - /// - /// Specified that the type or property it is applied to should never be - /// destructured; instead it should be logged as an atomic value. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)] - public class LogAsScalarAttribute : Attribute - { - readonly bool _isMutable; - - /// - /// Construct a . - /// - /// Whether the scalar value should be converted into a string before - /// being passed down the (asynchronous) logging pipeline. For mutable types, specify - /// true, otherwise leave as false. - public LogAsScalarAttribute(bool isMutable = false) - { - _isMutable = isMutable; - } - - /// - /// Whether the scalar value should be converted into a string before being passed to the pipeline. - /// - public bool IsMutable - { - get { return _isMutable; } - } - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Attributed/Extras/Attributed/NotLoggedAttribute.cs b/src/Serilog.Extras.Attributed/Extras/Attributed/NotLoggedAttribute.cs deleted file mode 100644 index dc097cca8..000000000 --- a/src/Serilog.Extras.Attributed/Extras/Attributed/NotLoggedAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; - -namespace Serilog.Extras.Attributed -{ - /// - /// Specified that a property should not be included when destructuring an object for logging. - /// - [AttributeUsage(AttributeTargets.Property)] - public class NotLoggedAttribute : Attribute - { - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Attributed/LoggerConfigurationAttributedExtensions.cs b/src/Serilog.Extras.Attributed/LoggerConfigurationAttributedExtensions.cs deleted file mode 100644 index 41640eb48..000000000 --- a/src/Serilog.Extras.Attributed/LoggerConfigurationAttributedExtensions.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Serilog.Configuration; -using Serilog.Extras.Attributed; - -namespace Serilog -{ - /// - /// Adds the Destructure.UsingAttributes() extension to . - /// - public static class LoggerConfigurationAppSettingsExtensions - { - /// - /// - /// The logger configuration to apply configuration to. - /// An object allowing configuration to continue. - public static LoggerConfiguration UsingAttributes(this LoggerDestructuringConfiguration configuration) - { - return configuration.With(); - } - } -} - diff --git a/src/Serilog.Extras.Attributed/Properties/AssemblyInfo.cs b/src/Serilog.Extras.Attributed/Properties/AssemblyInfo.cs deleted file mode 100644 index add72f17d..000000000 --- a/src/Serilog.Extras.Attributed/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyTitle("Serilog.Extras.Attributed")] -[assembly: AssemblyProduct("Serilog Attribute-Driven Destructuring Support")] -[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2014")] \ No newline at end of file diff --git a/src/Serilog.Extras.Attributed/Serilog.Extras.Attributed.csproj b/src/Serilog.Extras.Attributed/Serilog.Extras.Attributed.csproj deleted file mode 100644 index abc8692d2..000000000 --- a/src/Serilog.Extras.Attributed/Serilog.Extras.Attributed.csproj +++ /dev/null @@ -1,83 +0,0 @@ - - - - - 11.0 - Debug - AnyCPU - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2} - Library - Properties - Serilog - Serilog.Extras.Attributed - en-US - 512 - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile78 - v4.5 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - bin\Debug\Serilog.Extras.Attributed.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - bin\Release\Serilog.Extras.Attributed.XML - - - true - - - ..\..\assets\Serilog.snk - - - - - Serilog.snk - - - Designer - - - - - Extras\Attributed\GetablePropertyFinder.cs - - - - - - - - Properties\CommonAssemblyInfo.cs - - - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog - - - - - - \ No newline at end of file diff --git a/src/Serilog.Extras.Attributed/Serilog.Extras.Attributed.nuspec b/src/Serilog.Extras.Attributed/Serilog.Extras.Attributed.nuspec deleted file mode 100644 index 1c25eb088..000000000 --- a/src/Serilog.Extras.Attributed/Serilog.Extras.Attributed.nuspec +++ /dev/null @@ -1,17 +0,0 @@ - - - - Serilog.Extras.Attributed - $version$ - Serilog Contributors - Adds support for specifying how complex types are destructured for logging using attributes. - en-US - http://serilog.net - http://www.apache.org/licenses/LICENSE-2.0 - http://serilog.net/images/serilog-nuget.png - serilog xml - - - - - diff --git a/test/Serilog.Extras.Attributed.Tests/AttributedDestructuringTests.cs b/test/Serilog.Extras.Attributed.Tests/AttributedDestructuringTests.cs deleted file mode 100644 index 5cb43918b..000000000 --- a/test/Serilog.Extras.Attributed.Tests/AttributedDestructuringTests.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Linq; -using NUnit.Framework; -using Serilog.Events; -using Serilog.Tests.Support; - -namespace Serilog.Extras.Attributed.Tests -{ - [LogAsScalar] - public class ImmutableScalar { } - - [LogAsScalar(isMutable: true)] - public class MutableScalar { } - - public class NotAScalar { } - - public class Customized - { - // ReSharper disable UnusedAutoPropertyAccessor.Global - public ImmutableScalar ImmutableScalar { get; set; } - public MutableScalar MutableScalar { get; set; } - public NotAScalar NotAScalar { get; set; } - - [NotLogged] - public string Ignored { get; set; } - - [LogAsScalar] - public NotAScalar ScalarAnyway { get; set; } - } - - [TestFixture] - public class AttributedDestructuringTests - { - [Test] - public void AttributesAreConsultedWhenDestructuring() - { - LogEvent evt = null; - - var log = new LoggerConfiguration() - .Destructure.UsingAttributes() - .WriteTo.Sink(new DelegatingSink(e => evt = e)) - .CreateLogger(); - - var customized = new Customized - { - ImmutableScalar = new ImmutableScalar(), - MutableScalar = new MutableScalar(), - NotAScalar = new NotAScalar(), - Ignored = "Hello, there", - ScalarAnyway = new NotAScalar() - }; - - log.Information("Here is {@Customized}", customized); - - var sv = (StructureValue)evt.Properties["Customized"]; - var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value); - - Assert.IsInstanceOf(props["ImmutableScalar"].LiteralValue()); - Assert.AreEqual(new MutableScalar().ToString(), props["MutableScalar"].LiteralValue()); - Assert.IsInstanceOf(props["NotAScalar"]); - Assert.IsFalse(props.ContainsKey("Ignored")); - Assert.IsInstanceOf(props["ScalarAnyway"].LiteralValue()); - } - } -} diff --git a/test/Serilog.Extras.Attributed.Tests/Properties/AssemblyInfo.cs b/test/Serilog.Extras.Attributed.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 8f35f218f..000000000 --- a/test/Serilog.Extras.Attributed.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -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("Serilog.Extras.Attributed.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Serilog.Extras.Attributed.Tests")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("cfdee457-ff29-4ec0-8d8b-82353481685e")] - -// 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/test/Serilog.Extras.Attributed.Tests/Serilog.Extras.Attributed.Tests.csproj b/test/Serilog.Extras.Attributed.Tests/Serilog.Extras.Attributed.Tests.csproj deleted file mode 100644 index 328dbe61c..000000000 --- a/test/Serilog.Extras.Attributed.Tests/Serilog.Extras.Attributed.Tests.csproj +++ /dev/null @@ -1,76 +0,0 @@ - - - - - Debug - AnyCPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92} - Library - Properties - Serilog.Extras.Attributed.Tests - Serilog.Extras.Attributed.Tests - v4.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - - - - - - - - - - - - - - - - - - {a79f906e-0298-49dc-93ec-ce4f1f5d13e2} - Serilog.Extras.Attributed - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog - - - {D5648551-D19D-41E3-9FC1-E74B111EEF41} - Serilog.Tests - - - - - - - - \ No newline at end of file diff --git a/test/Serilog.Extras.Attributed.Tests/packages.config b/test/Serilog.Extras.Attributed.Tests/packages.config deleted file mode 100644 index ad37a5282..000000000 --- a/test/Serilog.Extras.Attributed.Tests/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 67e5314fa46d561c567ba6dbaffe18a950aed772 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Sun, 29 Mar 2015 18:53:59 +1000 Subject: [PATCH 08/10] Removed Serilog.Extras.FSharp and Serilog.Extras.DestructureByIgnoring - these are now in https://github.com/destructurama (#414). --- Serilog.sln | 21 ----- .../DestructureByIgnoringPolicy.cs | 87 ------------------ .../IgnoredPropertyExpressionExtensions.cs | 58 ------------ .../LoggerConfigurationIgnoreExtensions.cs | 39 -------- .../Properties/AssemblyInfo.cs | 5 -- ...erilog.Extras.DestructureByIgnoring.csproj | 78 ---------------- ...erilog.Extras.DestructureByIgnoring.nuspec | 17 ---- .../Serilog.Extras.FSharp.fsproj | 68 -------------- .../Serilog.Extras.FSharp.nuspec | 22 ----- .../SerilogExtrasFSharp.fs | 51 ----------- .../DestructureByIgnoringTests.cs | 88 ------------------- .../Properties/AssemblyInfo.cs | 35 -------- ....Extras.DestructureByIgnoring.Tests.csproj | 79 ----------------- .../packages.config | 4 - 14 files changed, 652 deletions(-) delete mode 100644 src/Serilog.Extras.DestructureByIgnoring/Extras/DestructureByIgnoring/DestructureByIgnoringPolicy.cs delete mode 100644 src/Serilog.Extras.DestructureByIgnoring/Extras/DestructureByIgnoring/IgnoredPropertyExpressionExtensions.cs delete mode 100644 src/Serilog.Extras.DestructureByIgnoring/LoggerConfigurationIgnoreExtensions.cs delete mode 100644 src/Serilog.Extras.DestructureByIgnoring/Properties/AssemblyInfo.cs delete mode 100644 src/Serilog.Extras.DestructureByIgnoring/Serilog.Extras.DestructureByIgnoring.csproj delete mode 100644 src/Serilog.Extras.DestructureByIgnoring/Serilog.Extras.DestructureByIgnoring.nuspec delete mode 100644 src/Serilog.Extras.FSharp/Serilog.Extras.FSharp.fsproj delete mode 100644 src/Serilog.Extras.FSharp/Serilog.Extras.FSharp.nuspec delete mode 100644 src/Serilog.Extras.FSharp/SerilogExtrasFSharp.fs delete mode 100644 test/Serilog.Extras.DestructureByIgnoring.Tests/DestructureByIgnoringTests.cs delete mode 100644 test/Serilog.Extras.DestructureByIgnoring.Tests/Properties/AssemblyInfo.cs delete mode 100644 test/Serilog.Extras.DestructureByIgnoring.Tests/Serilog.Extras.DestructureByIgnoring.Tests.csproj delete mode 100644 test/Serilog.Extras.DestructureByIgnoring.Tests/packages.config diff --git a/Serilog.sln b/Serilog.sln index 6d6497ed1..b866992a8 100644 --- a/Serilog.sln +++ b/Serilog.sln @@ -36,12 +36,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.SmokeTest", "test\S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.AppSettings.Tests", "test\Serilog.Extras.AppSettings.Tests\Serilog.Extras.AppSettings.Tests.csproj", "{67398D2A-0829-4373-ABC5-2161FEB28A05}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.DestructureByIgnoring", "src\Serilog.Extras.DestructureByIgnoring\Serilog.Extras.DestructureByIgnoring.csproj", "{C5CC62F4-310F-495C-96EA-B8E5D26F8D57}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.DestructureByIgnoring.Tests", "test\Serilog.Extras.DestructureByIgnoring.Tests\Serilog.Extras.DestructureByIgnoring.Tests.csproj", "{977E42C3-D501-4730-98FF-525B753B1E3A}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Serilog.Extras.FSharp", "src\Serilog.Extras.FSharp\Serilog.Extras.FSharp.fsproj", "{088A4030-7C7A-4434-964A-8E9E42DB17F0}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.MsTests", "test\Serilog.MsTests\Serilog.MsTests.csproj", "{7FC9FC46-5014-4461-A448-815E6CCE21E5}" EndProject Global @@ -90,18 +84,6 @@ Global {67398D2A-0829-4373-ABC5-2161FEB28A05}.Debug|Any CPU.Build.0 = Debug|Any CPU {67398D2A-0829-4373-ABC5-2161FEB28A05}.Release|Any CPU.ActiveCfg = Release|Any CPU {67398D2A-0829-4373-ABC5-2161FEB28A05}.Release|Any CPU.Build.0 = Release|Any CPU - {C5CC62F4-310F-495C-96EA-B8E5D26F8D57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C5CC62F4-310F-495C-96EA-B8E5D26F8D57}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C5CC62F4-310F-495C-96EA-B8E5D26F8D57}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C5CC62F4-310F-495C-96EA-B8E5D26F8D57}.Release|Any CPU.Build.0 = Release|Any CPU - {977E42C3-D501-4730-98FF-525B753B1E3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {977E42C3-D501-4730-98FF-525B753B1E3A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {977E42C3-D501-4730-98FF-525B753B1E3A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {977E42C3-D501-4730-98FF-525B753B1E3A}.Release|Any CPU.Build.0 = Release|Any CPU - {088A4030-7C7A-4434-964A-8E9E42DB17F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {088A4030-7C7A-4434-964A-8E9E42DB17F0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {088A4030-7C7A-4434-964A-8E9E42DB17F0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {088A4030-7C7A-4434-964A-8E9E42DB17F0}.Release|Any CPU.Build.0 = Release|Any CPU {7FC9FC46-5014-4461-A448-815E6CCE21E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7FC9FC46-5014-4461-A448-815E6CCE21E5}.Debug|Any CPU.Build.0 = Debug|Any CPU {7FC9FC46-5014-4461-A448-815E6CCE21E5}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -121,9 +103,6 @@ Global {4F81EDAE-2E06-4024-925A-E495C852BDCF} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {58563C46-B781-4799-ABD5-9745F94478FD} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {67398D2A-0829-4373-ABC5-2161FEB28A05} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} - {C5CC62F4-310F-495C-96EA-B8E5D26F8D57} = {037440DE-440B-4129-9F7A-09B42D00397E} - {977E42C3-D501-4730-98FF-525B753B1E3A} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} - {088A4030-7C7A-4434-964A-8E9E42DB17F0} = {037440DE-440B-4129-9F7A-09B42D00397E} {7FC9FC46-5014-4461-A448-815E6CCE21E5} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} EndGlobalSection EndGlobal diff --git a/src/Serilog.Extras.DestructureByIgnoring/Extras/DestructureByIgnoring/DestructureByIgnoringPolicy.cs b/src/Serilog.Extras.DestructureByIgnoring/Extras/DestructureByIgnoring/DestructureByIgnoringPolicy.cs deleted file mode 100644 index 3dd3b61b2..000000000 --- a/src/Serilog.Extras.DestructureByIgnoring/Extras/DestructureByIgnoring/DestructureByIgnoringPolicy.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using Serilog.Core; -using Serilog.Debugging; -using Serilog.Events; - -namespace Serilog.Extras.DestructureByIgnoring -{ - class DestructureByIgnoringPolicy : IDestructuringPolicy - { - private readonly IEnumerable _propertiesToInclude; - private readonly Type _destructureType; - - public DestructureByIgnoringPolicy(params Expression>[] ignoredProperties) - { - _destructureType = typeof(TDestructure); - var namesOfPropertiesToIgnore = ignoredProperties.Select(GetNameOfPropertyToIgnore).ToArray(); - var runtimeProperties = _destructureType.GetRuntimeProperties(); - - _propertiesToInclude = runtimeProperties.Where(p => !namesOfPropertiesToIgnore.Contains(p.Name)).ToArray(); - } - - public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventPropertyValue result) - { - if (value == null || value.GetType() != typeof(TDestructure)) - { - result = null; - return false; - } - - result = BuildStructure(value, propertyValueFactory); - - return true; - } - - private LogEventPropertyValue BuildStructure(object value, ILogEventPropertyValueFactory propertyValueFactory) - { - var structureProperties = new List(); - foreach (var propertyInfo in _propertiesToInclude) - { - object propertyValue; - try - { - propertyValue = propertyInfo.GetValue(value); - } - catch (TargetInvocationException ex) - { - SelfLog.WriteLine("The property accessor {0} threw exception {1}", propertyInfo, ex); - propertyValue = "The property accessor threw an exception: " + ex.InnerException.GetType().Name; - } - - var logEventPropertyValue = BuildLogEventProperty(propertyValue, propertyValueFactory); - - structureProperties.Add(new LogEventProperty(propertyInfo.Name, logEventPropertyValue)); - } - - return new StructureValue(structureProperties, _destructureType.Name); - } - - private static LogEventPropertyValue BuildLogEventProperty(object propertyValue, ILogEventPropertyValueFactory propertyValueFactory) - { - return propertyValue == null ? new ScalarValue(null) : propertyValueFactory.CreatePropertyValue(propertyValue, true); - } - - private static string GetNameOfPropertyToIgnore(Expression> ignoredProperty) - { - return ignoredProperty.GetPropertyNameFromExpression(); - } - } -} diff --git a/src/Serilog.Extras.DestructureByIgnoring/Extras/DestructureByIgnoring/IgnoredPropertyExpressionExtensions.cs b/src/Serilog.Extras.DestructureByIgnoring/Extras/DestructureByIgnoring/IgnoredPropertyExpressionExtensions.cs deleted file mode 100644 index 474086af3..000000000 --- a/src/Serilog.Extras.DestructureByIgnoring/Extras/DestructureByIgnoring/IgnoredPropertyExpressionExtensions.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Linq.Expressions; - -namespace Serilog.Extras.DestructureByIgnoring -{ - static class IgnoredPropertyExpressionExtensions - { - private const string expressionNotSupported = "A property name cannot be retrieved from function expression with body of type {0}. " + - "Only function expressions that access a property are currently supported. e.g. obj => obj.Property"; - - public static string GetPropertyNameFromExpression(this Expression> ignoredProperty) - { - var expressionBody = ignoredProperty.Body; - - var memberExpression = GetMemberExpression(expressionBody); - - var isNotSimplePropertyAccess = memberExpression == null || GetMemberExpression(memberExpression.Expression) != null; - if (isNotSimplePropertyAccess) - { - throw new ArgumentException(string.Format(expressionNotSupported, - expressionBody.GetType().Name), "ignoredProperty"); - } - - return memberExpression.Member.Name; - } - - private static MemberExpression GetMemberExpression(Expression expression) - { - return GetMemberExpressionForValueType(expression) ?? GetMemberExpressionForReferenceType(expression); - } - - private static MemberExpression GetMemberExpressionForValueType(Expression expression) - { - var bodyOfExpression = expression as UnaryExpression; - - return bodyOfExpression != null ? bodyOfExpression.Operand as MemberExpression : null; - } - - private static MemberExpression GetMemberExpressionForReferenceType(Expression expression) - { - return expression as MemberExpression; - } - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.DestructureByIgnoring/LoggerConfigurationIgnoreExtensions.cs b/src/Serilog.Extras.DestructureByIgnoring/LoggerConfigurationIgnoreExtensions.cs deleted file mode 100644 index 0985e3772..000000000 --- a/src/Serilog.Extras.DestructureByIgnoring/LoggerConfigurationIgnoreExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Linq.Expressions; -using Serilog.Configuration; -using Serilog.Extras.DestructureByIgnoring; - -namespace Serilog -{ - /// - /// Adds the Destructure.ByIgnoringProperties() extension to . - /// - public static class LoggerConfigurationIgnoreExtensions - { - /// - /// Destructure.ByIgnoringProperties takes one or more expressions that access a property, e.g. obj => obj.Property, and uses the property names to determine which - /// properties are ignored when an object of type TDestruture is destructured by serilog. - /// - /// The logger configuration to apply configuration to. - /// The function expressions that expose the properties to ignore. - /// An object allowing configuration to continue. - public static LoggerConfiguration ByIgnoringProperties(this LoggerDestructuringConfiguration configuration, params Expression>[] ignoredProperty) - { - return configuration.With(new DestructureByIgnoringPolicy(ignoredProperty)); - } - } -} diff --git a/src/Serilog.Extras.DestructureByIgnoring/Properties/AssemblyInfo.cs b/src/Serilog.Extras.DestructureByIgnoring/Properties/AssemblyInfo.cs deleted file mode 100644 index 4d6d27197..000000000 --- a/src/Serilog.Extras.DestructureByIgnoring/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyTitle("Serilog.Extras.DestructureByIgnoring")] -[assembly: AssemblyProduct("Serilog Lambda-Driven Destructuring Support")] -[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2014")] \ No newline at end of file diff --git a/src/Serilog.Extras.DestructureByIgnoring/Serilog.Extras.DestructureByIgnoring.csproj b/src/Serilog.Extras.DestructureByIgnoring/Serilog.Extras.DestructureByIgnoring.csproj deleted file mode 100644 index a925e9f3d..000000000 --- a/src/Serilog.Extras.DestructureByIgnoring/Serilog.Extras.DestructureByIgnoring.csproj +++ /dev/null @@ -1,78 +0,0 @@ - - - - - 11.0 - Debug - AnyCPU - {C5CC62F4-310F-495C-96EA-B8E5D26F8D57} - Library - Properties - Serilog - Serilog.Extras.DestructureByIgnoring - en-US - 512 - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile78 - v4.5 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - bin\Debug\Serilog.Extras.DestructureByIgnoring.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - bin\Release\Serilog.Extras.DestructureByIgnoring.XML - - - true - - - ..\..\assets\Serilog.snk - - - - - Serilog.snk - - - Designer - - - - - - - - - Properties\CommonAssemblyInfo.cs - - - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog - - - - - \ No newline at end of file diff --git a/src/Serilog.Extras.DestructureByIgnoring/Serilog.Extras.DestructureByIgnoring.nuspec b/src/Serilog.Extras.DestructureByIgnoring/Serilog.Extras.DestructureByIgnoring.nuspec deleted file mode 100644 index 61a6bd9d7..000000000 --- a/src/Serilog.Extras.DestructureByIgnoring/Serilog.Extras.DestructureByIgnoring.nuspec +++ /dev/null @@ -1,17 +0,0 @@ - - - - Serilog.Extras.DestructureByIgnoring - $version$ - Serilog Contributors - Adds support for specifying how complex types are destructured for logging using lamda expressions to ignore specific properties. - en-US - http://serilog.net - http://www.apache.org/licenses/LICENSE-2.0 - http://serilog.net/images/serilog-nuget.png - serilog - - - - - diff --git a/src/Serilog.Extras.FSharp/Serilog.Extras.FSharp.fsproj b/src/Serilog.Extras.FSharp/Serilog.Extras.FSharp.fsproj deleted file mode 100644 index e3e5437f9..000000000 --- a/src/Serilog.Extras.FSharp/Serilog.Extras.FSharp.fsproj +++ /dev/null @@ -1,68 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - 088a4030-7c7a-4434-964a-8e9e42db17f0 - Library - Serilog.Extras.FSharp - Serilog.Extras.FSharp - v4.5 - Profile7 - netcore - 3.3.1.0 - Serilog.Extras.FSharp - - - true - full - false - false - bin\Debug\ - DEBUG;TRACE - 3 - bin\Debug\Serilog.Extras.FSharp.XML - true - - - - pdbonly - true - true - bin\Release\ - TRACE - 3 - bin\Release\Serilog.Extras.FSharp.XML - true - - - - 12 - - - - - - - - - FSharp.Core - FSharp.Core.dll - $(MSBuildExtensionsPath32)\..\Reference Assemblies\Microsoft\FSharp\.NETCore\$(TargetFSharpCoreVersion)\FSharp.Core.dll - - - Serilog - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - True - - - - \ No newline at end of file diff --git a/src/Serilog.Extras.FSharp/Serilog.Extras.FSharp.nuspec b/src/Serilog.Extras.FSharp/Serilog.Extras.FSharp.nuspec deleted file mode 100644 index 132dd31c0..000000000 --- a/src/Serilog.Extras.FSharp/Serilog.Extras.FSharp.nuspec +++ /dev/null @@ -1,22 +0,0 @@ - - - - Serilog.Extras.FSharp - $version$ - Serilog Contributors - Adds support for F# language constructs to Serilog. - en-US - http://serilog.net - http://www.apache.org/licenses/LICENSE-2.0 - http://serilog.net/images/serilog-nuget.png - serilog fsharp - - - - - - - - - - diff --git a/src/Serilog.Extras.FSharp/SerilogExtrasFSharp.fs b/src/Serilog.Extras.FSharp/SerilogExtrasFSharp.fs deleted file mode 100644 index 9970d3110..000000000 --- a/src/Serilog.Extras.FSharp/SerilogExtrasFSharp.fs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace Serilog.Extras.FSharp - -open Microsoft.FSharp.Reflection -open Serilog.Core -open Serilog.Events - -// Based on the sample from @vlaci in https://github.com/serilog/serilog/issues/352 - -type public UnionDestructuringPolicy() = - interface Serilog.Core.IDestructuringPolicy with - member this.TryDestructure(value, - propertyValueFactory : ILogEventPropertyValueFactory, - result: byref) = - if FSharpType.IsUnion(value.GetType()) then - let case, fields = FSharpValue.GetUnionFields(value, value.GetType()) - - let properties = Seq.zip (case.GetFields()) fields |> - Seq.map(fun (n, v) -> LogEventProperty( - n.Name, - propertyValueFactory.CreatePropertyValue(v, true))) - - result <- StructureValue(properties, case.Name) - true - else - false - -namespace Serilog - -open Serilog.Configuration -open Serilog.Extras.FSharp - -[] -module public LoggerDestructuringConfigurationExtensions = - type public LoggerDestructuringConfiguration with - member public this.FSharpTypes() = - this.With() - diff --git a/test/Serilog.Extras.DestructureByIgnoring.Tests/DestructureByIgnoringTests.cs b/test/Serilog.Extras.DestructureByIgnoring.Tests/DestructureByIgnoringTests.cs deleted file mode 100644 index 112be77b7..000000000 --- a/test/Serilog.Extras.DestructureByIgnoring.Tests/DestructureByIgnoringTests.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Linq; -using System.Linq.Expressions; -using NUnit.Framework; -using Serilog.Events; -using Serilog.Tests.Support; - -namespace Serilog.Extras.DestructureByIgnoring.Tests -{ - [TestFixture] - public class DestructureByIgnoringTests - { - class DestructureMe - { - public int Id { get; set; } - public string Name { get; set; } - public string Password { get; set; } - } - - [Test] - public void PropertyNamesInExpressionsAreIgnoredWhenDestructuring() - { - LogEvent evt = null; - - Expression> valueTypeProperty = dm => dm.Id; - Expression> referenceTypeProperty = dm => dm.Password; - - var log = new LoggerConfiguration() - .Destructure.ByIgnoringProperties(valueTypeProperty, referenceTypeProperty) - .WriteTo.Sink(new DelegatingSink(e => evt = e)) - .CreateLogger(); - - var ignored = new DestructureMe - { - Id = 2, - Name = "Name", - Password = "Password" - }; - - log.Information("Here is {@Ignored}", ignored); - - var sv = (StructureValue)evt.Properties["Ignored"]; - var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value); - - Assert.IsFalse(props.ContainsKey("Id"), "Id property should have been ignored"); - Assert.IsFalse(props.ContainsKey("Password"), "Password property should have been ignored."); - Assert.AreEqual("Name", props["Name"].LiteralValue()); - } - - [Test] - public void ComplexExpressionsFail() - { - AssertUnsupportedExpression(dm => new - { - Name = dm.Name - }); - } - - [Test] - public void MethodExpressionsFail() - { - AssertUnsupportedExpression(dm => dm.ToString()); - } - - [Test] - public void StringLiteralExpressionsFail() - { - AssertUnsupportedExpression(dm => "string literal"); - } - - [Test] - public void ChainedPropertyExpressionsFail() - { - AssertUnsupportedExpression(dm => dm.Password.Length); - } - - private void AssertUnsupportedExpression(Expression> expressionThatShouldFail) - { - var ex = Assert.Throws(() => - new LoggerConfiguration() - .Destructure - .ByIgnoringProperties(expressionThatShouldFail) - ); - - Assert.That(ex.ParamName, Is.EqualTo("ignoredProperty")); - } - } -} diff --git a/test/Serilog.Extras.DestructureByIgnoring.Tests/Properties/AssemblyInfo.cs b/test/Serilog.Extras.DestructureByIgnoring.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index bdc27c681..000000000 --- a/test/Serilog.Extras.DestructureByIgnoring.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -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("Serilog.Extras.DestructureByIgnoring.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Serilog.Extras.DestructureByIgnoring.Tests")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5fd4eb08-0ad6-4ce4-b403-113a97160559")] - -// 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/test/Serilog.Extras.DestructureByIgnoring.Tests/Serilog.Extras.DestructureByIgnoring.Tests.csproj b/test/Serilog.Extras.DestructureByIgnoring.Tests/Serilog.Extras.DestructureByIgnoring.Tests.csproj deleted file mode 100644 index c38c46e0f..000000000 --- a/test/Serilog.Extras.DestructureByIgnoring.Tests/Serilog.Extras.DestructureByIgnoring.Tests.csproj +++ /dev/null @@ -1,79 +0,0 @@ - - - - - Debug - AnyCPU - {977E42C3-D501-4730-98FF-525B753B1E3A} - Library - Properties - Serilog.Extras.DestructureByIgnoring.Tests - Serilog.Extras.DestructureByIgnoring.Tests - v4.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - ..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - - - - - - - - - - - - - - - - - - {c5cc62f4-310f-495c-96ea-b8e5d26f8d57} - Serilog.Extras.DestructureByIgnoring - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog - - - {D5648551-D19D-41E3-9FC1-E74B111EEF41} - Serilog.Tests - - - - - - - - \ No newline at end of file diff --git a/test/Serilog.Extras.DestructureByIgnoring.Tests/packages.config b/test/Serilog.Extras.DestructureByIgnoring.Tests/packages.config deleted file mode 100644 index 967502dc8..000000000 --- a/test/Serilog.Extras.DestructureByIgnoring.Tests/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 3f7154bd487b1dab4c4a7355e33dd28b3e3aa298 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Sun, 29 Mar 2015 19:12:35 +1000 Subject: [PATCH 09/10] Remove the FSharp proj from Build.ps1 --- Build.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index 427345b9a..4f0c22184 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -52,10 +52,6 @@ function Invoke-NuGetPack($version) pushd .\src\Serilog Invoke-NuGetPackSpec "Serilog.nuspec" $version popd - - pushd .\src\Serilog.Extras.FSharp - Invoke-NuGetPackSpec "Serilog.Extras.FSharp.nuspec" $version - popd } function Invoke-Build($majorMinor, $patch, $customLogger, $notouch) From fa5f0f5d408310f15fe7d4ccae1ffd3d7a4e7bbb Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 7 Apr 2015 21:33:31 +1000 Subject: [PATCH 10/10] Moved Serilog.Extras.Web to https://github.com/serilog-web/classic and Serilog.Extras.MSOwin to https://github.com/serilog-web/owin This was a trailing part of #344 --- Serilog.sln | 21 ---- .../Extras/MSOwin/AppBuilderExtensions.cs | 35 ------ .../Extras/MSOwin/LoggerFactory.cs | 111 ----------------- .../Extras/MSOwin/RequestContextMiddleware.cs | 66 ----------- .../Properties/AssemblyInfo.cs | 5 - .../Serilog.Extras.MSOwin.csproj | 81 ------------- .../Serilog.Extras.MSOwin.nuspec | 19 --- src/Serilog.Extras.MSOwin/packages.config | 5 - .../Extras/Web/ApplicationLifecycleModule.cs | 112 ------------------ .../HttpRequestClientHostIPEnricher.cs | 107 ----------------- .../HttpRequestClientHostNameEnricher.cs | 59 --------- .../Web/Enrichers/HttpRequestIdEnricher.cs | 57 --------- .../Enrichers/HttpRequestNumberEnricher.cs | 60 ---------- .../Enrichers/HttpRequestRawUrlEnricher.cs | 59 --------- .../Enrichers/HttpRequestTraceIdEnricher.cs | 54 --------- .../Web/Enrichers/HttpRequestTypeEnricher.cs | 59 --------- .../Web/Enrichers/HttpRequestUrlEnricher.cs | 60 ---------- .../HttpRequestUrlReferrerEnricher.cs | 59 --------- .../Enrichers/HttpRequestUserAgentEnricher.cs | 59 --------- .../Web/Enrichers/HttpSessionIdEnricher.cs | 51 -------- .../Extras/Web/Enrichers/UserNameEnricher.cs | 77 ------------ .../Properties/AssemblyInfo.cs | 9 -- .../Serilog.Extras.Web.csproj | 87 -------------- .../Serilog.Extras.Web.nuspec | 17 --- .../Extras/MSOwin/LoggerFactoryTests.cs | 60 ---------- .../MSOwin/RequestContextMiddlewareTests.cs | 63 ---------- .../Serilog.Extras.MSOwin.Tests.csproj | 91 -------------- .../packages.config | 13 -- 28 files changed, 1556 deletions(-) delete mode 100644 src/Serilog.Extras.MSOwin/Extras/MSOwin/AppBuilderExtensions.cs delete mode 100644 src/Serilog.Extras.MSOwin/Extras/MSOwin/LoggerFactory.cs delete mode 100644 src/Serilog.Extras.MSOwin/Extras/MSOwin/RequestContextMiddleware.cs delete mode 100644 src/Serilog.Extras.MSOwin/Properties/AssemblyInfo.cs delete mode 100644 src/Serilog.Extras.MSOwin/Serilog.Extras.MSOwin.csproj delete mode 100644 src/Serilog.Extras.MSOwin/Serilog.Extras.MSOwin.nuspec delete mode 100644 src/Serilog.Extras.MSOwin/packages.config delete mode 100644 src/Serilog.Extras.Web/Extras/Web/ApplicationLifecycleModule.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestClientHostIPEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestClientHostNameEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestIdEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestNumberEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestRawUrlEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestTraceIdEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestTypeEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUrlEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUrlReferrerEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUserAgentEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpSessionIdEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Extras/Web/Enrichers/UserNameEnricher.cs delete mode 100644 src/Serilog.Extras.Web/Properties/AssemblyInfo.cs delete mode 100644 src/Serilog.Extras.Web/Serilog.Extras.Web.csproj delete mode 100644 src/Serilog.Extras.Web/Serilog.Extras.Web.nuspec delete mode 100644 test/Serilog.Extras.MSOwin.Tests/Extras/MSOwin/LoggerFactoryTests.cs delete mode 100644 test/Serilog.Extras.MSOwin.Tests/Extras/MSOwin/RequestContextMiddlewareTests.cs delete mode 100644 test/Serilog.Extras.MSOwin.Tests/Serilog.Extras.MSOwin.Tests.csproj delete mode 100644 test/Serilog.Extras.MSOwin.Tests/packages.config diff --git a/Serilog.sln b/Serilog.sln index b866992a8..9242be609 100644 --- a/Serilog.sln +++ b/Serilog.sln @@ -24,14 +24,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.FullNetFx", "src\Se EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.PerformanceTests", "test\Serilog.PerformanceTests\Serilog.PerformanceTests.csproj", "{6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.Web", "src\Serilog.Extras.Web\Serilog.Extras.Web.csproj", "{13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.AppSettings", "src\Serilog.Extras.AppSettings\Serilog.Extras.AppSettings.csproj", "{21CAF132-BBAB-41FD-A018-EB9AE54822ED}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.MSOwin", "src\Serilog.Extras.MSOwin\Serilog.Extras.MSOwin.csproj", "{FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.MSOwin.Tests", "test\Serilog.Extras.MSOwin.Tests\Serilog.Extras.MSOwin.Tests.csproj", "{4F81EDAE-2E06-4024-925A-E495C852BDCF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.SmokeTest", "test\Serilog.SmokeTest\Serilog.SmokeTest.csproj", "{58563C46-B781-4799-ABD5-9745F94478FD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.AppSettings.Tests", "test\Serilog.Extras.AppSettings.Tests\Serilog.Extras.AppSettings.Tests.csproj", "{67398D2A-0829-4373-ABC5-2161FEB28A05}" @@ -60,22 +54,10 @@ Global {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A}.Release|Any CPU.Build.0 = Release|Any CPU - {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD}.Release|Any CPU.Build.0 = Release|Any CPU {21CAF132-BBAB-41FD-A018-EB9AE54822ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21CAF132-BBAB-41FD-A018-EB9AE54822ED}.Debug|Any CPU.Build.0 = Debug|Any CPU {21CAF132-BBAB-41FD-A018-EB9AE54822ED}.Release|Any CPU.ActiveCfg = Release|Any CPU {21CAF132-BBAB-41FD-A018-EB9AE54822ED}.Release|Any CPU.Build.0 = Release|Any CPU - {FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}.Release|Any CPU.Build.0 = Release|Any CPU - {4F81EDAE-2E06-4024-925A-E495C852BDCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F81EDAE-2E06-4024-925A-E495C852BDCF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4F81EDAE-2E06-4024-925A-E495C852BDCF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4F81EDAE-2E06-4024-925A-E495C852BDCF}.Release|Any CPU.Build.0 = Release|Any CPU {58563C46-B781-4799-ABD5-9745F94478FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {58563C46-B781-4799-ABD5-9745F94478FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {58563C46-B781-4799-ABD5-9745F94478FD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -97,10 +79,7 @@ Global {D5648551-D19D-41E3-9FC1-E74B111EEF41} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {7A9E1095-167D-402A-B43D-B36B97FF183D} = {037440DE-440B-4129-9F7A-09B42D00397E} {6A6504BF-CD5B-4C9E-88EB-5BD71CE3106A} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} - {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD} = {037440DE-440B-4129-9F7A-09B42D00397E} {21CAF132-BBAB-41FD-A018-EB9AE54822ED} = {037440DE-440B-4129-9F7A-09B42D00397E} - {FDCEBC10-F403-4DDD-8594-DE6D7DD543AF} = {037440DE-440B-4129-9F7A-09B42D00397E} - {4F81EDAE-2E06-4024-925A-E495C852BDCF} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {58563C46-B781-4799-ABD5-9745F94478FD} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {67398D2A-0829-4373-ABC5-2161FEB28A05} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} {7FC9FC46-5014-4461-A448-815E6CCE21E5} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0} diff --git a/src/Serilog.Extras.MSOwin/Extras/MSOwin/AppBuilderExtensions.cs b/src/Serilog.Extras.MSOwin/Extras/MSOwin/AppBuilderExtensions.cs deleted file mode 100644 index 5475228ff..000000000 --- a/src/Serilog.Extras.MSOwin/Extras/MSOwin/AppBuilderExtensions.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Owin; - -namespace Serilog.Extras.MSOwin -{ - /// - /// Extends with support for installing Serilog middleware. - /// - public static class AppBuilderExtensions - { - /// - /// Open a nested diagnostic context for each request allowing the correlation of log messages per request. - /// - /// The IAppBuilder passed to your configuration method - /// The property name the request Id is associated with. Default is - /// The original app parameter - public static IAppBuilder UseSerilogRequestContext(this IAppBuilder app, string propertyName = RequestContextMiddleware.DefaultRequestIdPropertyName) - { - return app.Use(typeof(RequestContextMiddleware), new object[]{ propertyName }); - } - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.MSOwin/Extras/MSOwin/LoggerFactory.cs b/src/Serilog.Extras.MSOwin/Extras/MSOwin/LoggerFactory.cs deleted file mode 100644 index c1e59ce11..000000000 --- a/src/Serilog.Extras.MSOwin/Extras/MSOwin/LoggerFactory.cs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Diagnostics; -using Microsoft.Owin.Logging; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.MSOwin -{ - /// - /// Implementation of Microsoft.Owin.Logger.ILoggerFactory. - /// - public class LoggerFactory : ILoggerFactory - { - readonly Func _getLogger; - readonly Func _getLogEventLevel; - - /// - /// Create a logger factory. - /// - /// The logger; if not provided the global will be used. - /// - public LoggerFactory(ILogger logger = null, Func getLogEventLevel = null) - { - _getLogger = logger == null ? (Func) (() => Log.Logger) : (() => logger); - _getLogEventLevel = getLogEventLevel ?? ToLogEventLevel; - } - - /// - /// Creates a new ILogger instance of the given name. - /// - /// The logger context name. - /// A logger instance. - public Microsoft.Owin.Logging.ILogger Create(string name) - { - return new Logger(_getLogger().ForContext(Constants.SourceContextPropertyName, name), _getLogEventLevel); - } - - static LogEventLevel ToLogEventLevel(TraceEventType traceEventType) - { - switch (traceEventType) - { - case TraceEventType.Critical: - return LogEventLevel.Fatal; - case TraceEventType.Error: - return LogEventLevel.Error; - case TraceEventType.Warning: - return LogEventLevel.Warning; - case TraceEventType.Information: - return LogEventLevel.Information; - case TraceEventType.Verbose: - return LogEventLevel.Verbose; - case TraceEventType.Start: - return LogEventLevel.Debug; - case TraceEventType.Stop: - return LogEventLevel.Debug; - case TraceEventType.Suspend: - return LogEventLevel.Debug; - case TraceEventType.Resume: - return LogEventLevel.Debug; - case TraceEventType.Transfer: - return LogEventLevel.Debug; - default: - throw new ArgumentOutOfRangeException("traceEventType"); - } - } - - class Logger : Microsoft.Owin.Logging.ILogger - { - readonly ILogger _logger; - readonly Func _getLogEventLevel; - - internal Logger(ILogger logger, Func getLogEventLevel) - { - _logger = logger; - _getLogEventLevel = getLogEventLevel; - } - - public bool WriteCore(TraceEventType eventType, int eventId, object state, Exception exception, Func formatter) - { - var level = _getLogEventLevel(eventType); - - // According to docs http://katanaproject.codeplex.com/SourceControl/latest#src/Microsoft.Owin/Logging/ILogger.cs - // "To check IsEnabled call WriteCore with only TraceEventType and check the return value, no event will be written." - if (state == null) - { - return _logger.IsEnabled(level); - } - if (!_logger.IsEnabled(level)) - { - return false; - } - _logger.Write(level, exception, formatter(state, exception)); - return true; - } - } - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.MSOwin/Extras/MSOwin/RequestContextMiddleware.cs b/src/Serilog.Extras.MSOwin/Extras/MSOwin/RequestContextMiddleware.cs deleted file mode 100644 index e7bd79576..000000000 --- a/src/Serilog.Extras.MSOwin/Extras/MSOwin/RequestContextMiddleware.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Serilog.Context; - -namespace Serilog.Extras.MSOwin -{ - /// - /// Adds a RequestId property to the logging context during request processing. - /// - public class RequestContextMiddleware - { - /// - /// The property name carrying the request ID. - /// - public const string DefaultRequestIdPropertyName = "RequestId"; - - readonly Func, Task> _next; - readonly string _propertyName; - - /// - /// Construct the middleware. - /// - /// - /// - /// - public RequestContextMiddleware(Func, Task> next, string propertyName = DefaultRequestIdPropertyName) - { - if (next == null) - { - throw new ArgumentNullException("next"); - } - _next = next; - _propertyName = string.IsNullOrWhiteSpace(propertyName) ? DefaultRequestIdPropertyName : propertyName; - } - - /// - /// Process a request. - /// - /// - /// - public async Task Invoke(IDictionary environment) - { - // There is not yet a standard way to uniquely identify and correlate an owin request - // ... hence 'RequestId' https://github.com/owin/owin/issues/21 - using (LogContext.PushProperty(_propertyName, Guid.NewGuid())) - { - await _next(environment); - } - } - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.MSOwin/Properties/AssemblyInfo.cs b/src/Serilog.Extras.MSOwin/Properties/AssemblyInfo.cs deleted file mode 100644 index 0bd0ee657..000000000 --- a/src/Serilog.Extras.MSOwin/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyTitle("Serilog.Extras.MSOwin")] -[assembly: AssemblyDescription("Middleware and logging support for OWIN using Serilog")] -[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2014")] \ No newline at end of file diff --git a/src/Serilog.Extras.MSOwin/Serilog.Extras.MSOwin.csproj b/src/Serilog.Extras.MSOwin/Serilog.Extras.MSOwin.csproj deleted file mode 100644 index 406f0cf3c..000000000 --- a/src/Serilog.Extras.MSOwin/Serilog.Extras.MSOwin.csproj +++ /dev/null @@ -1,81 +0,0 @@ - - - - - Debug - AnyCPU - {FDCEBC10-F403-4DDD-8594-DE6D7DD543AF} - Library - Properties - Serilog - Serilog.Extras.MSOwin - v4.5 - 512 - ..\..\ - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Serilog.Extras.MSOwin.XML - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Serilog.Extras.MSOwin.XML - true - - - true - - - ..\..\assets\Serilog.snk - - - - ..\..\packages\Microsoft.Owin.2.1.0\lib\net45\Microsoft.Owin.dll - - - ..\..\packages\Owin.1.0\lib\net40\Owin.dll - - - - - - - - - - - Properties\CommonAssemblyInfo.cs - - - - - - Serilog.snk - - - - - - - {7A9E1095-167D-402A-B43D-B36B97FF183D} - Serilog.FullNetFx - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog - - - - \ No newline at end of file diff --git a/src/Serilog.Extras.MSOwin/Serilog.Extras.MSOwin.nuspec b/src/Serilog.Extras.MSOwin/Serilog.Extras.MSOwin.nuspec deleted file mode 100644 index 1cc391c19..000000000 --- a/src/Serilog.Extras.MSOwin/Serilog.Extras.MSOwin.nuspec +++ /dev/null @@ -1,19 +0,0 @@ - - - - Serilog.Extras.MSOwin - $version$ - Serilog Contributors - Provides request correlation middleware and integration with Microsoft.Owin logging. - en-US - http://serilog.net - http://www.apache.org/licenses/LICENSE-2.0 - http://serilog.net/images/serilog-nuget.png - serilog logging owin - - - - - - - diff --git a/src/Serilog.Extras.MSOwin/packages.config b/src/Serilog.Extras.MSOwin/packages.config deleted file mode 100644 index fb47f58ce..000000000 --- a/src/Serilog.Extras.MSOwin/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Extras/Web/ApplicationLifecycleModule.cs b/src/Serilog.Extras.Web/Extras/Web/ApplicationLifecycleModule.cs deleted file mode 100644 index c0f911897..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/ApplicationLifecycleModule.cs +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Linq; -using System.Web; -using Serilog.Events; - -namespace Serilog.Extras.Web -{ - /// - /// HTTP module that logs application request and error events. - /// - public class ApplicationLifecycleModule : IHttpModule - { - static volatile bool _logPostedFormData; - static volatile bool _isEnabled = true; - static volatile LogEventLevel _requestLoggingLevel = LogEventLevel.Information; - - /// - /// Register the module with the application (called automatically; - /// do not call this explicitly from your code). - /// - public static void Register() - { - HttpApplication.RegisterModule(typeof(ApplicationLifecycleModule)); - } - - /// - /// When set to true, form data will be written via a debug-level event. - /// The default is false. Requires that is also - /// true (which it is, by default). - /// - public static bool DebugLogPostedFormData - { - get { return _logPostedFormData; } - set { _logPostedFormData = value; } - } - - /// - /// When set to true, request details and errors will be logged. The default - /// is true. - /// - public static bool IsEnabled - { - get { return _isEnabled; } - set { _isEnabled = value; } - } - - /// - /// The level at which to log HTTP requests. The default is Information. - /// - public static LogEventLevel RequestLoggingLevel - { - get { return _requestLoggingLevel; } - set { _requestLoggingLevel = value; } - } - - /// - /// Initializes a module and prepares it to handle requests. - /// - /// An that provides access to the methods, properties, and events common to all application objects within an ASP.NET application - public void Init(HttpApplication context) - { - context.LogRequest +=LogRequest; - context.Error += Error; - } - - static void LogRequest(object sender, EventArgs e) - { - if (!_isEnabled) return; - - var request = HttpContext.Current.Request; - Log.Write(_requestLoggingLevel, "HTTP {Method} for {RawUrl}", request.HttpMethod, request.RawUrl); - if (_logPostedFormData && Log.IsEnabled(LogEventLevel.Debug)) - { - var form = request.Form; - if (form.HasKeys()) - { - var formData = form.AllKeys.SelectMany(k => (form.GetValues(k) ?? new string[0]).Select(v => new { Name = k, Value = v })); - Log.Debug("Client provided {@FormData}", formData); - } - } - } - - static void Error(object sender, EventArgs e) - { - if (!_isEnabled) return; - - var ex = ((HttpApplication)sender).Server.GetLastError(); - Log.Error(ex, "Error caught in global handler: {ExceptionMessage}", ex.Message); - } - - /// - /// Disposes of the resources (other than memory) used by the module that implements . - /// - public void Dispose() - { - } - } -} diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestClientHostIPEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestClientHostIPEnricher.cs deleted file mode 100644 index c786a66da..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestClientHostIPEnricher.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Linq; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the Client IP Address. - /// - public class HttpRequestClientHostIPEnricher : ILogEventEnricher - { - /// - /// Gets or sets a value indicating whether this enricher will check for possible HTTP proxies via X-FORWARDED-FOR headers. - /// - /// - /// true if [check for HTTP proxies]; otherwise, false. - /// - public bool CheckForHttpProxies { get; set; } - - /// - /// Initializes a new instance of the class with set to [true]. - /// - public HttpRequestClientHostIPEnricher() - { - CheckForHttpProxies = true; - } - - /// - /// Initializes a new instance of the class. - /// - /// if set to true this Enricher also checks for HTTP proxies and their X-FORWARDED-FOR header. - public HttpRequestClientHostIPEnricher(bool checkForHttpProxies) - { - CheckForHttpProxies = checkForHttpProxies; - } - - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestClientHostIPPropertyName = "HttpRequestClientHostIP"; - - #region Implementation of ILogEventEnricher - - /// - /// Enrich the log event. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - if (HttpContext.Current.Request == null) - return; - - if (string.IsNullOrWhiteSpace(HttpContext.Current.Request.UserHostAddress)) - return; - - string userHostAddress; - - // Taking Proxy/-ies into consideration, too (if wanted and available) - if (CheckForHttpProxies) - { - userHostAddress = !string.IsNullOrWhiteSpace(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]) - ? HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] - : HttpContext.Current.Request.UserHostAddress; - } - else - { - userHostAddress = HttpContext.Current.Request.UserHostAddress; - } - - if (string.IsNullOrWhiteSpace(userHostAddress)) - return; - - // As multiple proxies can be in place according to header spec (see http://en.wikipedia.org/wiki/X-Forwarded-For), we check for it and only extract the first address (which 'should' be the actual client one) - if (userHostAddress.Contains(",")) - { - userHostAddress = userHostAddress.Split(',').First().Trim(); - } - - var httpRequestClientHostIPProperty = new LogEventProperty(HttpRequestClientHostIPPropertyName, new ScalarValue(userHostAddress)); - logEvent.AddPropertyIfAbsent(httpRequestClientHostIPProperty); - } - - #endregion - } -} diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestClientHostNameEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestClientHostNameEnricher.cs deleted file mode 100644 index e5b6a9f1c..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestClientHostNameEnricher.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the Client Host Name. - /// - public class HttpRequestClientHostNameEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestClientHostNamePropertyName = "HttpRequestClientHostName"; - - #region Implementation of ILogEventEnricher - - /// - /// Enrich the log event. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - if (HttpContext.Current.Request == null) - return; - - if (string.IsNullOrWhiteSpace(HttpContext.Current.Request.UserHostName)) - return; - - var userHostName = HttpContext.Current.Request.UserHostName; - var httpRequestClientHostnameProperty = new LogEventProperty(HttpRequestClientHostNamePropertyName, new ScalarValue(userHostName)); - logEvent.AddPropertyIfAbsent(httpRequestClientHostnameProperty); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestIdEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestIdEnricher.cs deleted file mode 100644 index 08507743e..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestIdEnricher.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with a HttpRequestId GUID. - /// - public class HttpRequestIdEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestIdPropertyName = "HttpRequestId"; - - static readonly string RequestIdItemName = typeof(HttpRequestIdEnricher).Name + "+RequestId"; - - /// - /// Enrich the log event with an id assigned to the currently-executing HTTP request, if any. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - Guid requestId; - var requestIdItem = HttpContext.Current.Items[RequestIdItemName]; - if (requestIdItem == null) - HttpContext.Current.Items[RequestIdItemName] = requestId = Guid.NewGuid(); - else - requestId = (Guid)requestIdItem; - - var requestIdProperty = new LogEventProperty(HttpRequestIdPropertyName, new ScalarValue(requestId)); - logEvent.AddPropertyIfAbsent(requestIdProperty); - } - } -} diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestNumberEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestNumberEnricher.cs deleted file mode 100644 index 85493fbde..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestNumberEnricher.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Threading; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with a HttpRequestNumber unique within the current - /// logging session. - /// - public class HttpRequestNumberEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestNumberPropertyName = "HttpRequestNumber"; - - static int LastRequestNumber; - static readonly string RequestNumberItemName = typeof(HttpRequestNumberEnricher).Name + "+RequestNumber"; - - /// - /// Enrich the log event with the number assigned to the currently-executing HTTP request, if any. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - int requestNumber; - var requestNumberItem = HttpContext.Current.Items[RequestNumberItemName]; - if (requestNumberItem == null) - HttpContext.Current.Items[RequestNumberItemName] = requestNumber = Interlocked.Increment(ref LastRequestNumber); - else - requestNumber = (int)requestNumberItem; - - var requestNumberProperty = new LogEventProperty(HttpRequestNumberPropertyName, new ScalarValue(requestNumber)); - logEvent.AddPropertyIfAbsent(requestNumberProperty); - } - } -} diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestRawUrlEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestRawUrlEnricher.cs deleted file mode 100644 index dfcab55cc..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestRawUrlEnricher.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the Raw Url of the Request. - /// - public class HttpRequestRawUrlEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestRawUrlPropertyName = "HttpRequestRawUrl"; - - #region Implementation of ILogEventEnricher - - /// - /// Enrich the log event. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - if (HttpContext.Current.Request == null) - return; - - if (string.IsNullOrWhiteSpace(HttpContext.Current.Request.RawUrl)) - return; - - var requestRawUrl = HttpContext.Current.Request.RawUrl; - var httpRequestRawUrlProperty = new LogEventProperty(HttpRequestRawUrlPropertyName, new ScalarValue(requestRawUrl)); - logEvent.AddPropertyIfAbsent(httpRequestRawUrlProperty); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestTraceIdEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestTraceIdEnricher.cs deleted file mode 100644 index f40cdc19d..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestTraceIdEnricher.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with a HttpRequestTraceId GUID matching the - /// RequestTraceIdentifier assigned by IIS and used throughout - /// ASP.NET/ETW. IIS ETW tracing must be enabled for this to work. - /// - public class HttpRequestTraceIdEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestTraceIdPropertyName = "HttpRequestTraceId"; - - /// - /// Enrich the log event with an id assigned to the currently-executing HTTP request, if any. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - var serviceProvider = (IServiceProvider)HttpContext.Current; - var workerRequest = (HttpWorkerRequest)serviceProvider.GetService(typeof(HttpWorkerRequest)); - var requestId = workerRequest.RequestTraceIdentifier; - - var requestIdProperty = new LogEventProperty(HttpRequestTraceIdPropertyName, new ScalarValue(requestId)); - logEvent.AddPropertyIfAbsent(requestIdProperty); - } - } -} diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestTypeEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestTypeEnricher.cs deleted file mode 100644 index ea8beb9de..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestTypeEnricher.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the HTTP Request Type. - /// - public class HttpRequestTypeEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestTypePropertyName = "HttpRequestType"; - - #region Implementation of ILogEventEnricher - - /// - /// Enrich the log event. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - if (HttpContext.Current.Request == null) - return; - - if (string.IsNullOrWhiteSpace(HttpContext.Current.Request.RequestType)) - return; - - var requestType = HttpContext.Current.Request.RequestType; - var httpRequestTypeProperty = new LogEventProperty(HttpRequestTypePropertyName, new ScalarValue(requestType)); - logEvent.AddPropertyIfAbsent(httpRequestTypeProperty); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUrlEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUrlEnricher.cs deleted file mode 100644 index 50f3b1044..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUrlEnricher.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the Url of the Request. - /// For the full, raw Url . - /// - public class HttpRequestUrlEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestUrlPropertyName = "HttpRequestUrl"; - - #region Implementation of ILogEventEnricher - - /// - /// Enrich the log event. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - if (HttpContext.Current.Request == null) - return; - - if (HttpContext.Current.Request.Url == null) - return; - - var requestUrl = HttpContext.Current.Request.Url.ToString(); - var httpRequestUrlProperty = new LogEventProperty(HttpRequestUrlPropertyName, new ScalarValue(requestUrl)); - logEvent.AddPropertyIfAbsent(httpRequestUrlProperty); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUrlReferrerEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUrlReferrerEnricher.cs deleted file mode 100644 index 0c1759238..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUrlReferrerEnricher.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the Url of the Referrer. - /// - public class HttpRequestUrlReferrerEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestUrlReferrerPropertyName = "HttpRequestUrlReferrer"; - - #region Implementation of ILogEventEnricher - - /// - /// Enrich the log event. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - if (HttpContext.Current.Request == null) - return; - - if (HttpContext.Current.Request.UrlReferrer == null) - return; - - var requestUrlReferrer = HttpContext.Current.Request.UrlReferrer.ToString(); - var httpRequestUrlReferrerProperty = new LogEventProperty(HttpRequestUrlReferrerPropertyName, new ScalarValue(requestUrlReferrer)); - logEvent.AddPropertyIfAbsent(httpRequestUrlReferrerProperty); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUserAgentEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUserAgentEnricher.cs deleted file mode 100644 index fc523bcba..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpRequestUserAgentEnricher.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the Client User Agent. - /// - public class HttpRequestUserAgentEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpRequestUserAgentPropertyName = "HttpRequestUserAgent"; - - #region Implementation of ILogEventEnricher - - /// - /// Enrich the log event. - /// - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - if (HttpContext.Current.Request == null) - return; - - if (string.IsNullOrWhiteSpace(HttpContext.Current.Request.UserAgent)) - return; - - var userAgent = HttpContext.Current.Request.UserAgent; - var httpRequestUserAgentProperty = new LogEventProperty(HttpRequestUserAgentPropertyName, new ScalarValue(userAgent)); - logEvent.AddPropertyIfAbsent(httpRequestUserAgentProperty); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpSessionIdEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpSessionIdEnricher.cs deleted file mode 100644 index bec91ac32..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/HttpSessionIdEnricher.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 Serilog Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the HttpSessionId property. - /// - public class HttpSessionIdEnricher : ILogEventEnricher - { - /// - /// The property name added to enriched log events. - /// - public const string HttpSessionIdPropertyName = "HttpSessionId"; - - /// - /// Enrich the log event with the current ASP.NET session id, if sessions are enabled. - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - if (HttpContext.Current == null) - return; - - if (HttpContext.Current.Session == null) - return; - - var sessionId = HttpContext.Current.Session.SessionID; - var sessionIdProperty = new LogEventProperty(HttpSessionIdPropertyName, new ScalarValue(sessionId)); - logEvent.AddPropertyIfAbsent(sessionIdProperty); - } - } -} diff --git a/src/Serilog.Extras.Web/Extras/Web/Enrichers/UserNameEnricher.cs b/src/Serilog.Extras.Web/Extras/Web/Enrichers/UserNameEnricher.cs deleted file mode 100644 index 3cfac278c..000000000 --- a/src/Serilog.Extras.Web/Extras/Web/Enrichers/UserNameEnricher.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Web; -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Extras.Web.Enrichers -{ - /// - /// Enrich log events with the UserName property when available in the HttpContext. - /// - public class UserNameEnricher : ILogEventEnricher - { - readonly string _anonymousUsername; - readonly string _noneUsername; - - /// - /// The property name added to enriched log events. - /// - public const string UserNamePropertyName = "UserName"; - - /// - /// Initializes a new instance of the class. - /// - public UserNameEnricher() - : this("(anonymous)", null) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The anonymous username. Leave null if you do not want to use anonymous user names. By default it is (anonymous). - /// The none username. If there is no username to be found, it will output this username. Leave null (default) to ignore non usernames. - public UserNameEnricher(string anonymousUsername = "(anonymous)", string noneUsername = null) - { - _anonymousUsername = anonymousUsername; - _noneUsername = noneUsername; - } - - /// - /// Enrich the log event with the current ASP.NET user name, if User.Identity.IsAuthenticated is true. - /// The log event to enrich. - /// Factory for creating new properties to add to the event. - public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) - { - if (logEvent == null) - throw new ArgumentNullException("logEvent"); - - var userName = _noneUsername; - - if (HttpContext.Current != null) - { - var context = new HttpContextWrapper(HttpContext.Current); - - if (context.User != null) - { - if (context.User.Identity == null || context.User.Identity.IsAuthenticated == false) - { - if (_anonymousUsername != null) - userName = _anonymousUsername; - } - else - { - userName = context.User.Identity.Name; - } - } - } - - if (userName == null) - return; - - var userNameProperty = new LogEventProperty(UserNamePropertyName, new ScalarValue(userName)); - logEvent.AddPropertyIfAbsent(userNameProperty); - } - } -} \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Properties/AssemblyInfo.cs b/src/Serilog.Extras.Web/Properties/AssemblyInfo.cs deleted file mode 100644 index b692b2774..000000000 --- a/src/Serilog.Extras.Web/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Reflection; -using System.Web; -using Serilog.Extras.Web; - -[assembly: AssemblyTitle("Serilog.Web")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2013")] - -[assembly: PreApplicationStartMethod(typeof(ApplicationLifecycleModule), "Register")] \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Serilog.Extras.Web.csproj b/src/Serilog.Extras.Web/Serilog.Extras.Web.csproj deleted file mode 100644 index 8add7f3e0..000000000 --- a/src/Serilog.Extras.Web/Serilog.Extras.Web.csproj +++ /dev/null @@ -1,87 +0,0 @@ - - - - - Debug - AnyCPU - {13CEC8DD-6087-4FEE-AEC1-0511B8959CCD} - Library - Properties - Serilog - Serilog.Extras.Web - v4.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - bin\Debug\Serilog.Extras.Web.xml - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - bin\Release\Serilog.Extras.Web.xml - - - true - - - ..\..\assets\Serilog.snk - - - - - - - - - - - - - - - - - - - - - - - Properties\CommonAssemblyInfo.cs - - - - - - - - - - Serilog.snk - - - Designer - - - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog - - - - - \ No newline at end of file diff --git a/src/Serilog.Extras.Web/Serilog.Extras.Web.nuspec b/src/Serilog.Extras.Web/Serilog.Extras.Web.nuspec deleted file mode 100644 index cd87ddde8..000000000 --- a/src/Serilog.Extras.Web/Serilog.Extras.Web.nuspec +++ /dev/null @@ -1,17 +0,0 @@ - - - - Serilog.Extras.Web - $version$ - Serilog Contributors - An event enricher for Serilog that adds details of the executing ASP.NET HTTP request. Replaces the deprecated Serilog.Web package. - en-US - http://serilog.net - http://www.apache.org/licenses/LICENSE-2.0 - http://serilog.net/images/serilog-nuget.png - serilog logging aspnet - - - - - diff --git a/test/Serilog.Extras.MSOwin.Tests/Extras/MSOwin/LoggerFactoryTests.cs b/test/Serilog.Extras.MSOwin.Tests/Extras/MSOwin/LoggerFactoryTests.cs deleted file mode 100644 index 6367e821c..000000000 --- a/test/Serilog.Extras.MSOwin.Tests/Extras/MSOwin/LoggerFactoryTests.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Reactive.Linq; -using Microsoft.Owin.Logging; -using NUnit.Framework; -using Serilog.Events; - -namespace Serilog.Extras.MSOwin -{ - [TestFixture] - public class LoggerFactoryTests - { - [Test] - public void CanCreateLogger() - { - var loggerFactory = new LoggerFactory(); - - var logger = loggerFactory.Create("LoggerFactoryTests"); - - Assert.NotNull(logger); - } - - [Test] - public void EventsAreWritten() - { - var eventSeen = false; - var log = new LoggerConfiguration() - .WriteTo - .Observers(events => events - .Do(evt => { eventSeen = true; }) - .Subscribe()) - .CreateLogger(); - var loggerFactory = new LoggerFactory(log); - - loggerFactory - .Create("LoggerFactoryTests") - .WriteError("error"); - - Assert.True(eventSeen); - } - - [Test] - public void CanOverrideTraceEventToLogLevelConversion() - { - LogEvent eventSeen = null; - var log = new LoggerConfiguration() - .WriteTo - .Observers(events => events - .Do(evt => { eventSeen = evt; }) - .Subscribe()) - .CreateLogger(); - var loggerFactory = new LoggerFactory(log, traceEventType => LogEventLevel.Fatal); - - loggerFactory - .Create("LoggerFactoryTests") - .WriteError("error"); - - Assert.AreEqual(eventSeen.Level, LogEventLevel.Fatal); - } - } -} \ No newline at end of file diff --git a/test/Serilog.Extras.MSOwin.Tests/Extras/MSOwin/RequestContextMiddlewareTests.cs b/test/Serilog.Extras.MSOwin.Tests/Extras/MSOwin/RequestContextMiddlewareTests.cs deleted file mode 100644 index 58438b041..000000000 --- a/test/Serilog.Extras.MSOwin.Tests/Extras/MSOwin/RequestContextMiddlewareTests.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Reactive.Linq; -using System.Threading.Tasks; -using Owin; -using Microsoft.Owin.Testing; -using NUnit.Framework; -using Serilog.Events; - -namespace Serilog.Extras.MSOwin -{ - public class SerilogMiddlewareTests - { - [TestFixture] - public class WhenUsingARequestContext - { - LogEvent _eventSeen; - readonly TestServer _server; - - public WhenUsingARequestContext() - { - var logger = new LoggerConfiguration() - .WriteTo - .Observers(events => events - .Do(evt => { _eventSeen = evt; }) - .Subscribe()) - .Enrich - .FromLogContext() - .CreateLogger(); - Log.Logger = logger; - - _server = TestServer.Create( - app => app.UseSerilogRequestContext() - .Use((context, func) => - { - Log.Information("message"); - return Task.Delay(0); - })); - } - - [Test] - public async Task Should_have_request_id_in_logevent_properties() - { - await MakeRequest(); - - Assert.True(_eventSeen.Properties.ContainsKey(RequestContextMiddleware.DefaultRequestIdPropertyName)); - } - - [Test] - public async Task Request_id_should_be_a_guid() - { - await MakeRequest(); - - Guid _; - Assert.True(Guid.TryParse(_eventSeen.Properties[RequestContextMiddleware.DefaultRequestIdPropertyName].ToString(), out _)); - } - - async Task MakeRequest() - { - await _server.CreateRequest("/").GetAsync(); - } - } - } -} \ No newline at end of file diff --git a/test/Serilog.Extras.MSOwin.Tests/Serilog.Extras.MSOwin.Tests.csproj b/test/Serilog.Extras.MSOwin.Tests/Serilog.Extras.MSOwin.Tests.csproj deleted file mode 100644 index d7bf79193..000000000 --- a/test/Serilog.Extras.MSOwin.Tests/Serilog.Extras.MSOwin.Tests.csproj +++ /dev/null @@ -1,91 +0,0 @@ - - - - - Debug - AnyCPU - {4F81EDAE-2E06-4024-925A-E495C852BDCF} - Library - Properties - Serilog - Serilog.Extras.MSOwin.Tests - v4.5 - 512 - ..\..\ - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\Microsoft.Owin.2.1.0\lib\net45\Microsoft.Owin.dll - - - ..\..\packages\Microsoft.Owin.Hosting.2.1.0\lib\net45\Microsoft.Owin.Hosting.dll - - - ..\..\packages\Microsoft.Owin.Testing.2.1.0\lib\net45\Microsoft.Owin.Testing.dll - - - ..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - - ..\..\packages\Owin.1.0\lib\net40\Owin.dll - - - - - - ..\..\packages\Rx-Core.2.2.2\lib\net45\System.Reactive.Core.dll - - - False - ..\..\packages\Rx-Interfaces.2.2.2\lib\net45\System.Reactive.Interfaces.dll - - - ..\..\packages\Rx-Linq.2.2.2\lib\net45\System.Reactive.Linq.dll - - - ..\..\packages\Rx-PlatformServices.2.2.3\lib\net45\System.Reactive.PlatformServices.dll - - - - - - - - - - - - {FDCEBC10-F403-4DDD-8594-DE6D7DD543AF} - Serilog.Extras.MSOwin - - - {7a9e1095-167d-402a-b43d-b36b97ff183d} - Serilog.FullNetFx - - - {0915dbd9-0f7c-4439-8d9e-74c3d579b219} - Serilog - - - - - - - \ No newline at end of file diff --git a/test/Serilog.Extras.MSOwin.Tests/packages.config b/test/Serilog.Extras.MSOwin.Tests/packages.config deleted file mode 100644 index 6c559526c..000000000 --- a/test/Serilog.Extras.MSOwin.Tests/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file