From f7a87df451b292981ffc50efc44cc555f5770e40 Mon Sep 17 00:00:00 2001 From: Greg Kurts Date: Thu, 20 Apr 2023 22:35:51 -0500 Subject: [PATCH 1/7] Update package versions --- .../Spectre.Console.Extensions.Logging.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Spectre.Console.Extensions.Logging/Spectre.Console.Extensions.Logging.csproj b/src/Spectre.Console.Extensions.Logging/Spectre.Console.Extensions.Logging.csproj index 5287cda..3dab19a 100644 --- a/src/Spectre.Console.Extensions.Logging/Spectre.Console.Extensions.Logging.csproj +++ b/src/Spectre.Console.Extensions.Logging/Spectre.Console.Extensions.Logging.csproj @@ -16,8 +16,8 @@ - - + + From a23fec0ba333e3e1d9412da7bb2802c1c68bb52e Mon Sep 17 00:00:00 2001 From: Greg Kurts Date: Thu, 20 Apr 2023 22:38:52 -0500 Subject: [PATCH 2/7] Create dotnet.yml --- .github/workflows/dotnet.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..c2a74d0 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,26 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: .NET + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore From 8dd769621c3148eafd36013bc89324da3f03d664 Mon Sep 17 00:00:00 2001 From: Greg Kurts Date: Thu, 20 Apr 2023 22:41:36 -0500 Subject: [PATCH 3/7] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e38d45..8dc6195 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' + dotnet-version: '6.x.x' - name: Restore Tools shell: bash run: | @@ -48,4 +48,4 @@ jobs: files: | ./dist/package/*.nupkg env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f4f70a2ca910500e021342786d5df619bdb1436d Mon Sep 17 00:00:00 2001 From: Greg Kurts Date: Thu, 20 Apr 2023 22:42:35 -0500 Subject: [PATCH 4/7] Delete dotnet.yml --- .github/workflows/dotnet.yml | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml deleted file mode 100644 index c2a74d0..0000000 --- a/.github/workflows/dotnet.yml +++ /dev/null @@ -1,26 +0,0 @@ -# This workflow will build a .NET project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net - -name: .NET - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 6.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore From 6e6a5d81668755c52d7c696ae3c8c8e45486faad Mon Sep 17 00:00:00 2001 From: Greg Kurts Date: Thu, 20 Apr 2023 23:00:08 -0500 Subject: [PATCH 5/7] Add option for single line logging --- .../SpectreConsoleLogger.cs | 12 ++++++++++-- .../SpectreConsoleLoggerConfiguration.cs | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Spectre.Console.Extensions.Logging/SpectreConsoleLogger.cs b/src/Spectre.Console.Extensions.Logging/SpectreConsoleLogger.cs index 7545747..429faa7 100644 --- a/src/Spectre.Console.Extensions.Logging/SpectreConsoleLogger.cs +++ b/src/Spectre.Console.Extensions.Logging/SpectreConsoleLogger.cs @@ -45,8 +45,16 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except var categoryStr = _config.IncludeEventId ? _name + $"[grey][[{eventId.Id}]][/]" : _name; - _console.MarkupLine(prefix + categoryStr); - _console.MarkupLine(string.Empty.PadRight(6) + formatter(state, exception)); + + if (!_config.SingleLine) + { + _console.MarkupLine(prefix + categoryStr); + _console.MarkupLine(string.Empty.PadRight(6) + formatter(state, exception)); + } + else + { + _console.MarkupLine(prefix + categoryStr + " " + formatter(state, exception)); + } } } private string GetLevelMarkup(LogLevel level) { diff --git a/src/Spectre.Console.Extensions.Logging/SpectreConsoleLoggerConfiguration.cs b/src/Spectre.Console.Extensions.Logging/SpectreConsoleLoggerConfiguration.cs index a80b98b..c63cb65 100644 --- a/src/Spectre.Console.Extensions.Logging/SpectreConsoleLoggerConfiguration.cs +++ b/src/Spectre.Console.Extensions.Logging/SpectreConsoleLoggerConfiguration.cs @@ -11,5 +11,6 @@ public class SpectreConsoleLoggerConfiguration public AnsiConsoleSettings ConsoleSettings {get;set;} = null; public bool IncludePrefix {get;set;} = true; public bool IncludeEventId {get;set;} = false; + public bool SingleLine { get; set; } = false; } } From d3d00b3d37522919f5f88f6ec46f3508a7bfb92d Mon Sep 17 00:00:00 2001 From: Greg Kurts Date: Fri, 21 Apr 2023 07:45:40 -0500 Subject: [PATCH 6/7] Correct title in Readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3999c9b..2d8e1e4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Spectre.Cli.Extensions.DependencyInjection +# Spectre.Console.Extensions.Logging A highly opioninated logger implementation for [`Microsoft.Extensions.Logging`](https://www.nuget.org/packages/Microsoft.Extensions.Logging/) that uses [`Spectre.Console`](https://github.com/spectresystems/spectre.console) to write to the console. From 4ba5334fc2f90fe685521f1d6ae9c10f837a8a8c Mon Sep 17 00:00:00 2001 From: Greg Kurts Date: Fri, 21 Apr 2023 07:50:26 -0500 Subject: [PATCH 7/7] Revert "Update build.yml" This reverts commit 8dd769621c3148eafd36013bc89324da3f03d664. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8dc6195..4e38d45 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.x.x' + dotnet-version: '3.1.x' - name: Restore Tools shell: bash run: | @@ -48,4 +48,4 @@ jobs: files: | ./dist/package/*.nupkg env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file