From 665b2c771a0851755cc72f21bf4538453ede12f7 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Mon, 8 Dec 2014 15:24:21 -0800 Subject: [PATCH 01/12] Updating to dev NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 2d3b0cb8..f41e9c63 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From 9899629df27168151a4e977534f2befba7134690 Mon Sep 17 00:00:00 2001 From: SonjaKhan Date: Wed, 3 Dec 2014 12:02:34 -0800 Subject: [PATCH 02/12] moving the LogFormatter to Logging --- .../ConsoleLogger.cs | 9 +- .../NLogLoggerProvider.cs | 9 +- .../project.json | 13 +-- .../SerilogLogger.cs | 9 +- .../LogFormatter.cs | 107 ++++++++++++++++++ 5 files changed, 113 insertions(+), 34 deletions(-) create mode 100644 src/Microsoft.Framework.Logging/LogFormatter.cs diff --git a/src/Microsoft.Framework.Logging.Console/ConsoleLogger.cs b/src/Microsoft.Framework.Logging.Console/ConsoleLogger.cs index 3b175ef6..09761cad 100644 --- a/src/Microsoft.Framework.Logging.Console/ConsoleLogger.cs +++ b/src/Microsoft.Framework.Logging.Console/ConsoleLogger.cs @@ -52,14 +52,7 @@ public void Write(LogLevel logLevel, int eventId, object state, Exception except } else { - if (state != null) - { - message += state; - } - if (exception != null) - { - message += Environment.NewLine + exception; - } + message = LogFormatter.Formatter(state, exception); } if (string.IsNullOrEmpty(message)) { diff --git a/src/Microsoft.Framework.Logging.NLog/NLogLoggerProvider.cs b/src/Microsoft.Framework.Logging.NLog/NLogLoggerProvider.cs index 7844ee6c..83c4d413 100644 --- a/src/Microsoft.Framework.Logging.NLog/NLogLoggerProvider.cs +++ b/src/Microsoft.Framework.Logging.NLog/NLogLoggerProvider.cs @@ -44,14 +44,7 @@ public void Write( } else { - if (state != null) - { - message += state; - } - if (exception != null) - { - message += Environment.NewLine + exception; - } + LogFormatter.Formatter(state, exception); } if (!string.IsNullOrEmpty(message)) { diff --git a/src/Microsoft.Framework.Logging.NLog/project.json b/src/Microsoft.Framework.Logging.NLog/project.json index 0342ac08..507247fd 100644 --- a/src/Microsoft.Framework.Logging.NLog/project.json +++ b/src/Microsoft.Framework.Logging.NLog/project.json @@ -1,18 +1,11 @@ { "version": "1.0.0-*", "dependencies": { + "Microsoft.Framework.Logging": "1.0.0-*", "NLog": "3.1.0" }, "frameworks": { - "net45": { - "dependencies": { - "Microsoft.Framework.Logging.Interfaces": "1.0.0-*" - } - }, - "aspnet50": { - "dependencies": { - "Microsoft.Framework.Logging.Interfaces": { "version": "1.0.0-*", "type": "build" } - } - } + "net45": { }, + "aspnet50": { } } } \ No newline at end of file diff --git a/src/Microsoft.Framework.Logging.Serilog/SerilogLogger.cs b/src/Microsoft.Framework.Logging.Serilog/SerilogLogger.cs index 2c6be8df..1d1eadb6 100644 --- a/src/Microsoft.Framework.Logging.Serilog/SerilogLogger.cs +++ b/src/Microsoft.Framework.Logging.Serilog/SerilogLogger.cs @@ -53,14 +53,7 @@ public void Write(LogLevel logLevel, int eventId, object state, Exception except } else { - if (state != null) - { - message += state; - } - if (exception != null) - { - message += Environment.NewLine + exception; - } + message = LogFormatter.Formatter(state, exception); } if (string.IsNullOrEmpty(message)) { diff --git a/src/Microsoft.Framework.Logging/LogFormatter.cs b/src/Microsoft.Framework.Logging/LogFormatter.cs new file mode 100644 index 00000000..7485fe98 --- /dev/null +++ b/src/Microsoft.Framework.Logging/LogFormatter.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using JetBrains.Annotations; + +namespace Microsoft.Framework.Logging +{ + /// + /// Formatters for common logging scenarios. + /// + public static class LogFormatter + { + private const string space = " "; + + /// + /// Formats a message from the given state and exception, in the form + /// "state + /// exception". + /// If state is an , + /// is used to format the message, otherwise the state's ToString() is used. + /// + public static string Formatter(object state, Exception e) + { + var result = string.Empty; + if (state != null) + { + var structure = state as ILoggerStructure; + if (structure != null) + { + result += FormatStructure(structure); + } + else + { + result += state; + } + } + if (e != null) + { + result += Environment.NewLine + e; + } + + return result; + } + + /// + /// Formats an . + /// + /// The to format. + /// A string representation of the given . + public static string FormatStructure([NotNull] ILoggerStructure structure) + { + var builder = new StringBuilder(); + FormatStructure(structure, builder); + return builder.ToString(); + } + + /// + /// Formats an . + /// + /// The to format. + /// The to append to. + private static void FormatStructure([NotNull] ILoggerStructure structure, [NotNull] StringBuilder builder) + { + var values = structure.GetValues(); + if (values == null) + { + return; + } + + foreach (var kvp in values) + { + IEnumerable structureEnumerable; + ILoggerStructure loggerStructure; + builder.Append(kvp.Key); + builder.Append(": "); + if ((structureEnumerable = kvp.Value as IEnumerable) != null) + { + var valArray = structureEnumerable.ToArray(); + for (int j = 0; j < valArray.Length - 1; j++) + { + FormatStructure(valArray[j], builder); + builder.Append(", "); + } + if (valArray.Length > 0) + { + FormatStructure(valArray[valArray.Length - 1], builder); + } + } + else if ((loggerStructure = kvp.Value as ILoggerStructure) != null) + { + FormatStructure(loggerStructure, builder); + } + else + { + builder.Append(kvp.Value); + } + builder.Append(space); + } + // get rid of the extra whitespace + if (builder.Length > 0) + { + builder.Length -= space.Length; + } + } + } +} \ No newline at end of file From c2347380130f15330f090c45b896e327991f3902 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 15 Dec 2014 14:45:48 -0800 Subject: [PATCH 03/12] Reacting to System.Threading version changes --- src/Microsoft.Framework.Logging/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Framework.Logging/project.json b/src/Microsoft.Framework.Logging/project.json index 0bf825e0..436be3fd 100644 --- a/src/Microsoft.Framework.Logging/project.json +++ b/src/Microsoft.Framework.Logging/project.json @@ -21,7 +21,7 @@ "System.Diagnostics.TraceSource": "4.0.0-beta-*", "System.Globalization": "4.0.10-beta-*", "System.Linq": "4.0.0-beta-*", - "System.Threading": "4.0.0-beta-*", + "System.Threading": "4.0.10-beta-*", "Microsoft.Framework.Logging.Interfaces": { "version": "1.0.0-*", "type": "build" } } }, From d88ffc051fd6c923fbf093d593e902b6edaf52bc Mon Sep 17 00:00:00 2001 From: Brennan Date: Mon, 15 Dec 2014 13:16:08 -0800 Subject: [PATCH 04/12] Update tests to use official xunit --- test/Microsoft.Framework.Logging.Test/project.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.Framework.Logging.Test/project.json b/test/Microsoft.Framework.Logging.Test/project.json index 7cfa54d4..3a97fd0a 100644 --- a/test/Microsoft.Framework.Logging.Test/project.json +++ b/test/Microsoft.Framework.Logging.Test/project.json @@ -2,11 +2,11 @@ "dependencies": { "Microsoft.Framework.Logging.Console": "1.0.0-*", "Microsoft.Framework.Logging.Serilog": "1.0.0-*", - "Xunit.KRunner": "1.0.0-*" + "xunit.runner.kre": "1.0.0-*" }, "commands": { - "run": "Xunit.KRunner", - "test": "Xunit.KRunner" + "run": "xunit.runner.kre", + "test": "xunit.runner.kre" }, "frameworks": { "aspnet50": { From 9ec675eee4f8e8d14e0ab38109f795595e81993a Mon Sep 17 00:00:00 2001 From: Praburaj Date: Mon, 12 Jan 2015 11:08:14 -0800 Subject: [PATCH 05/12] Removing 'OWIN' from XML comments This addresses the bug https://github.com/aspnet/Logging/issues/18 --- src/Microsoft.Framework.Logging/DiagnosticsLoggerProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Framework.Logging/DiagnosticsLoggerProvider.cs b/src/Microsoft.Framework.Logging/DiagnosticsLoggerProvider.cs index ea281fc3..8b55c069 100644 --- a/src/Microsoft.Framework.Logging/DiagnosticsLoggerProvider.cs +++ b/src/Microsoft.Framework.Logging/DiagnosticsLoggerProvider.cs @@ -23,7 +23,7 @@ public class DiagnosticsLoggerProvider : ILoggerProvider /// Initializes a new instance of the class. /// /// - /// Creates a factory named "Microsoft.Owin". + /// Creates a factory named "Microsoft.AspNet". /// public DiagnosticsLoggerProvider() { From 38b62016c35ed246f571d938fa4998020498a6e9 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Mon, 12 Jan 2015 11:08:46 -0800 Subject: [PATCH 06/12] Removes 'OWIN' from XML comment Missed an instance: Addresses this bug https://github.com/aspnet/Logging/issues/18 --- src/Microsoft.Framework.Logging.Interfaces/ILogger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Framework.Logging.Interfaces/ILogger.cs b/src/Microsoft.Framework.Logging.Interfaces/ILogger.cs index 2681d20d..bca053a0 100644 --- a/src/Microsoft.Framework.Logging.Interfaces/ILogger.cs +++ b/src/Microsoft.Framework.Logging.Interfaces/ILogger.cs @@ -14,7 +14,7 @@ namespace Microsoft.Framework.Logging public interface ILogger { /// - /// Aggregates most logging patterns to a single method. This must be compatible with the Func representation in the OWIN environment. + /// Aggregates most logging patterns to a single method. /// /// /// From af53aecf800fdafe2a9532c254d2376caaf5dc13 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Tue, 13 Jan 2015 13:53:54 -0800 Subject: [PATCH 07/12] Fixing the logger extensions to take in params object[] instead of string[] Fixes bug # https://github.com/aspnet/Logging/issues/89 Right now the logger extensions take in params string[] as args for substitution values. This makes it painful to send basic CLR types and user code has to do a .ToString() on even basic CLR types. With this change it will be possible to possible the object as it is. --- .../LoggerExtensions.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.Framework.Logging/LoggerExtensions.cs b/src/Microsoft.Framework.Logging/LoggerExtensions.cs index b116897a..fad61b32 100644 --- a/src/Microsoft.Framework.Logging/LoggerExtensions.cs +++ b/src/Microsoft.Framework.Logging/LoggerExtensions.cs @@ -48,7 +48,7 @@ public static void WriteVerbose([NotNull] this ILogger logger, int eventId, stri /// The to write to. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteVerbose([NotNull] this ILogger logger, string format, params string[] args) + public static void WriteVerbose([NotNull] this ILogger logger, string format, params object[] args) { logger.Write(LogLevel.Verbose, 0, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -61,7 +61,7 @@ public static void WriteVerbose([NotNull] this ILogger logger, string format, pa /// The event id associated with the log. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteVerbose([NotNull] this ILogger logger, int eventId, string format, params string[] args) + public static void WriteVerbose([NotNull] this ILogger logger, int eventId, string format, params object[] args) { logger.Write(LogLevel.Verbose, eventId, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -126,7 +126,7 @@ public static void WriteInformation([NotNull] this ILogger logger, int eventId, /// The to write to. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteInformation([NotNull] this ILogger logger, string format, params string[] args) + public static void WriteInformation([NotNull] this ILogger logger, string format, params object[] args) { logger.Write(LogLevel.Information, 0, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -139,7 +139,7 @@ public static void WriteInformation([NotNull] this ILogger logger, string format /// The event id associated with the log. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteInformation([NotNull] this ILogger logger, int eventId, string format, params string[] args) + public static void WriteInformation([NotNull] this ILogger logger, int eventId, string format, params object[] args) { logger.Write(LogLevel.Information, eventId, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -204,7 +204,7 @@ public static void WriteWarning([NotNull] this ILogger logger, int eventId, stri /// The to write to. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteWarning([NotNull] this ILogger logger, string format, params string[] args) + public static void WriteWarning([NotNull] this ILogger logger, string format, params object[] args) { logger.Write(LogLevel.Warning, 0, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -217,7 +217,7 @@ public static void WriteWarning([NotNull] this ILogger logger, string format, pa /// The event id associated with the log. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteWarning([NotNull] this ILogger logger, int eventId, string format, params string[] args) + public static void WriteWarning([NotNull] this ILogger logger, int eventId, string format, params object[] args) { logger.Write(LogLevel.Warning, eventId, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -305,7 +305,7 @@ public static void WriteError([NotNull] this ILogger logger, int eventId, string /// The to write to. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteError([NotNull] this ILogger logger, string format, params string[] args) + public static void WriteError([NotNull] this ILogger logger, string format, params object[] args) { logger.Write(LogLevel.Error, 0, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -318,7 +318,7 @@ public static void WriteError([NotNull] this ILogger logger, string format, para /// The event id associated with the log. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteError([NotNull] this ILogger logger, int eventId, string format, params string[] args) + public static void WriteError([NotNull] this ILogger logger, int eventId, string format, params object[] args) { logger.Write(LogLevel.Error, eventId, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -406,7 +406,7 @@ public static void WriteCritical([NotNull] this ILogger logger, int eventId, str /// The to write to. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteCritical([NotNull] this ILogger logger, string format, params string[] args) + public static void WriteCritical([NotNull] this ILogger logger, string format, params object[] args) { logger.Write(LogLevel.Critical, 0, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); @@ -419,7 +419,7 @@ public static void WriteCritical([NotNull] this ILogger logger, string format, p /// The event id associated with the log. /// Format string of the log message. /// An object array that contains zero or more objects to format. - public static void WriteCritical([NotNull] this ILogger logger, int eventId, string format, params string[] args) + public static void WriteCritical([NotNull] this ILogger logger, int eventId, string format, params object[] args) { logger.Write(LogLevel.Critical, eventId, string.Format(CultureInfo.InvariantCulture, format, args), null, TheMessage); From 86b9a33a38a814c20f658980200a8fd63d44ce5a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Jan 2015 01:32:13 -0800 Subject: [PATCH 08/12] Updating build.cmd and build.sh to use dotnetsdk --- build.cmd | 6 +++--- build.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cmd b/build.cmd index 86ca5bbb..c8041fdd 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_KRE_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dotnetsdk use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index c7873ef5..3f3c731c 100755 --- a/build.sh +++ b/build.sh @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/kvm.sh + source setup/dotnetsdk.sh fi if ! type k > /dev/null 2>&1; then - kvm upgrade + dotnetsdk upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From afcd4dd443e172baad705a2214699a93e9c8b0bb Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Jan 2015 01:36:19 -0800 Subject: [PATCH 09/12] Updating build.cmd and build.sh to use dotnetsdk --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 3f3c731c..350d7e38 100755 --- a/build.sh +++ b/build.sh @@ -28,7 +28,7 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source setup/dotnetsdk.sh + source packages/KoreBuild/build/dotnetsdk.sh fi if ! type k > /dev/null 2>&1; then From 8d18062dc80b43e938cbe33bb33ffc5c0758876e Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 20 Jan 2015 18:26:07 -0800 Subject: [PATCH 10/12] Rename SKIP_KRE_INSTALL to SKIP_DOTNET_INSTALL --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index c8041fdd..220a1ff5 100644 --- a/build.cmd +++ b/build.cmd @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_KRE_INSTALL%"=="1" goto run +IF "%SKIP_DOTNET_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 From 4c42eadffccacc271f373b8b2622bd9e0cf8b6d5 Mon Sep 17 00:00:00 2001 From: Aligned Date: Wed, 21 Jan 2015 13:16:32 -0600 Subject: [PATCH 11/12] Change ASP.NET vNext to ASP.Net 5 in the Readme.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bdc3f706..b4245025 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Logging ======= -Contains common logging abstractions for ASP.NET vNext. Refer to the [wiki](https://github.com/aspnet/Logging/wiki) for more information +Contains common logging abstractions for ASP.NET 5. Refer to the [wiki](https://github.com/aspnet/Logging/wiki) for more information -This project is part of ASP.NET vNext. You can find samples, documentation and getting started instructions for ASP.NET vNext at the [Home](https://github.com/aspnet/home) repo. +This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. From 11bde39dbed28bf7699389cd38d25ccb9081c222 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Wed, 21 Jan 2015 15:46:37 -0800 Subject: [PATCH 12/12] Updating to release NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c63..2d3b0cb8 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - +