From 53ab99b8b64e86884fdfeec51f0e42a669f9fc03 Mon Sep 17 00:00:00 2001 From: nenoNaninu Date: Sun, 1 Dec 2024 13:27:11 +0900 Subject: [PATCH 1/4] update package --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 33ff25a..e92af95 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,7 +11,7 @@ - + From 56d2e23c58d829c201bdd242a20ed3b12919cbea Mon Sep 17 00:00:00 2001 From: nenoNaninu Date: Sun, 1 Dec 2024 13:27:47 +0900 Subject: [PATCH 2/4] add packages --- Directory.Packages.props | 3 +++ .../TypedSignalR.Client.TypeScript.Generator.csproj | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index e92af95..572cab1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,7 +11,10 @@ + + + diff --git a/src/TypedSignalR.Client.TypeScript.Generator/TypedSignalR.Client.TypeScript.Generator.csproj b/src/TypedSignalR.Client.TypeScript.Generator/TypedSignalR.Client.TypeScript.Generator.csproj index 6d5d7d5..a280835 100644 --- a/src/TypedSignalR.Client.TypeScript.Generator/TypedSignalR.Client.TypeScript.Generator.csproj +++ b/src/TypedSignalR.Client.TypeScript.Generator/TypedSignalR.Client.TypeScript.Generator.csproj @@ -27,6 +27,9 @@ + + + From 44b5798f3c389d0cc0408de02f063529923a2fce Mon Sep 17 00:00:00 2001 From: nenoNaninu Date: Sun, 1 Dec 2024 13:27:59 +0900 Subject: [PATCH 3/4] add SimpleConsoleAppFormatter --- .../Logging/SimpleConsoleAppFormatter.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/TypedSignalR.Client.TypeScript.Generator/Logging/SimpleConsoleAppFormatter.cs diff --git a/src/TypedSignalR.Client.TypeScript.Generator/Logging/SimpleConsoleAppFormatter.cs b/src/TypedSignalR.Client.TypeScript.Generator/Logging/SimpleConsoleAppFormatter.cs new file mode 100644 index 0000000..59a0cbb --- /dev/null +++ b/src/TypedSignalR.Client.TypeScript.Generator/Logging/SimpleConsoleAppFormatter.cs @@ -0,0 +1,38 @@ +using System.IO; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Console; + +namespace TypedSignalR.Client.TypeScript.Logging; + +internal static class ConsoleLoggerExtensions +{ + public static ILoggingBuilder AddSimpleConsoleApp(this ILoggingBuilder builder) + { + builder.AddConsole(options => options.FormatterName = SimpleConsoleAppFormatter.FormatterName) + .AddConsoleFormatter(); + + return builder; + } +} + +internal class SimpleConsoleAppFormatter : ConsoleFormatter +{ + public const string FormatterName = "SimpleConsoleApp"; + + public SimpleConsoleAppFormatter() : base(FormatterName) + { + } + + public override void Write(in LogEntry logEntry, IExternalScopeProvider? scopeProvider, TextWriter textWriter) + { + string message = logEntry.Formatter(logEntry.State, logEntry.Exception); + + if (message is null) + { + return; + } + + textWriter.WriteLine(message); + } +} From 09e85561efb7a8ce28085780c31285c24062b5bc Mon Sep 17 00:00:00 2001 From: nenoNaninu Date: Sun, 1 Dec 2024 13:28:53 +0900 Subject: [PATCH 4/4] use SimpleConsoleAppFormatter --- src/TypedSignalR.Client.TypeScript.Generator/Program.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/TypedSignalR.Client.TypeScript.Generator/Program.cs b/src/TypedSignalR.Client.TypeScript.Generator/Program.cs index 5d149b0..55ffb82 100644 --- a/src/TypedSignalR.Client.TypeScript.Generator/Program.cs +++ b/src/TypedSignalR.Client.TypeScript.Generator/Program.cs @@ -1,16 +1,13 @@ using Cocona; using Microsoft.Build.Locator; -using Microsoft.Extensions.Logging; using TypedSignalR.Client.TypeScript; +using TypedSignalR.Client.TypeScript.Logging; MSBuildLocator.RegisterDefaults(); var builder = CoconaApp.CreateBuilder(); -builder.Logging.AddSimpleConsole(options => -{ - options.SingleLine = true; -}); +builder.Logging.AddSimpleConsoleApp(); var app = builder.Build();