From e71c351245c733ea9e61dde4c06a0fcb4f62bf14 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Thu, 11 Jul 2024 15:52:29 -0700 Subject: [PATCH] Release 1.12.8 --- .github/workflows/develop-ci.yml | 5 ++-- .github/workflows/main-ci.yml | 5 ++-- .../Meadow.Logging.LogProviders.sln | 4 +-- .../CloudLogger_Sample.csproj | 2 +- .../FileLogger_Sample.csproj | 2 +- .../UdpLogger_Sample/UdpLogger_Sample.csproj | 2 +- Source/Meadow.Logging/lib/Logger.cs | 27 ++++++++++++++----- 7 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.github/workflows/develop-ci.yml b/.github/workflows/develop-ci.yml index 6373fb8..55bb380 100644 --- a/.github/workflows/develop-ci.yml +++ b/.github/workflows/develop-ci.yml @@ -3,6 +3,7 @@ name: Develop Build on: workflow_dispatch: pull_request: + branches: [ develop ] push: branches: [ develop ] @@ -16,7 +17,7 @@ jobs: - name: Checkout Meadow.Logging uses: actions/checkout@v3 with: - ref: develop + path: Meadow.Logging - name: Setup .NET uses: actions/setup-dotnet@v1 @@ -24,4 +25,4 @@ jobs: dotnet-version: 7.0.x - name: Build - run: dotnet build -c Release Source/Meadow.Logging/Meadow.Logging.sln + run: dotnet build -c Release Meadow.Logging/Source/Meadow.Logging/Meadow.Logging.sln diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml index c1511a1..42e6466 100644 --- a/.github/workflows/main-ci.yml +++ b/.github/workflows/main-ci.yml @@ -3,6 +3,7 @@ name: Main Build on: workflow_dispatch: pull_request: + branches: [ main ] push: branches: [ main ] @@ -16,7 +17,7 @@ jobs: - name: Checkout Meadow.Logging uses: actions/checkout@v3 with: - ref: main + path: Meadow.Logging - name: Setup .NET uses: actions/setup-dotnet@v1 @@ -24,4 +25,4 @@ jobs: dotnet-version: 7.0.x - name: Build - run: dotnet build -c Release Source/Meadow.Logging/Meadow.Logging.sln + run: dotnet build -c Release Meadow.Logging/Source/Meadow.Logging/Meadow.Logging.sln diff --git a/Source/Meadow.Logging.LogProviders/Meadow.Logging.LogProviders.sln b/Source/Meadow.Logging.LogProviders/Meadow.Logging.LogProviders.sln index a4e5da8..66fd1d7 100644 --- a/Source/Meadow.Logging.LogProviders/Meadow.Logging.LogProviders.sln +++ b/Source/Meadow.Logging.LogProviders/Meadow.Logging.LogProviders.sln @@ -21,9 +21,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Units", "..\..\..\Me EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet", "..\..\..\MQTTnet\Source\MQTTnet\MQTTnet.csproj", "{FC7ABF71-6F35-4590-B96F-B3E88EA3322F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Core", "..\..\..\Meadow.Core\source\Meadow.Core\Meadow.Core.csproj", "{C6BCFC1F-FA6F-46CB-91B6-7F32F0A2562B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Core", "..\..\..\Meadow.Core\Source\Meadow.Core\Meadow.Core.csproj", "{C6BCFC1F-FA6F-46CB-91B6-7F32F0A2562B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.F7", "..\..\..\Meadow.Core\source\implementations\f7\Meadow.F7\Meadow.F7.csproj", "{237FEFB7-1DB0-471D-B4EB-E4005E80D79B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.F7", "..\..\..\Meadow.Core\Source\implementations\f7\Meadow.F7\Meadow.F7.csproj", "{237FEFB7-1DB0-471D-B4EB-E4005E80D79B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UdpLogger_Sample", "Samples\UdpLogger_Sample\UdpLogger_Sample.csproj", "{A2180137-6CD6-4100-AC69-94BCC7808DBB}" EndProject diff --git a/Source/Meadow.Logging.LogProviders/Samples/CloudLogger_Sample/CloudLogger_Sample.csproj b/Source/Meadow.Logging.LogProviders/Samples/CloudLogger_Sample/CloudLogger_Sample.csproj index f5e98e8..2a5ab0e 100644 --- a/Source/Meadow.Logging.LogProviders/Samples/CloudLogger_Sample/CloudLogger_Sample.csproj +++ b/Source/Meadow.Logging.LogProviders/Samples/CloudLogger_Sample/CloudLogger_Sample.csproj @@ -7,7 +7,7 @@ 10 - + diff --git a/Source/Meadow.Logging.LogProviders/Samples/FileLogger_Sample/FileLogger_Sample.csproj b/Source/Meadow.Logging.LogProviders/Samples/FileLogger_Sample/FileLogger_Sample.csproj index d3a93e7..a4cf4ce 100644 --- a/Source/Meadow.Logging.LogProviders/Samples/FileLogger_Sample/FileLogger_Sample.csproj +++ b/Source/Meadow.Logging.LogProviders/Samples/FileLogger_Sample/FileLogger_Sample.csproj @@ -7,7 +7,7 @@ 10 - + diff --git a/Source/Meadow.Logging.LogProviders/Samples/UdpLogger_Sample/UdpLogger_Sample.csproj b/Source/Meadow.Logging.LogProviders/Samples/UdpLogger_Sample/UdpLogger_Sample.csproj index d3a93e7..a4cf4ce 100644 --- a/Source/Meadow.Logging.LogProviders/Samples/UdpLogger_Sample/UdpLogger_Sample.csproj +++ b/Source/Meadow.Logging.LogProviders/Samples/UdpLogger_Sample/UdpLogger_Sample.csproj @@ -7,7 +7,7 @@ 10 - + diff --git a/Source/Meadow.Logging/lib/Logger.cs b/Source/Meadow.Logging/lib/Logger.cs index 928c8a3..74ebc74 100644 --- a/Source/Meadow.Logging/lib/Logger.cs +++ b/Source/Meadow.Logging/lib/Logger.cs @@ -32,6 +32,11 @@ public static class MessageGroup /// Represents the application-specific log messages. /// public const string Application = "application"; + + /// + /// Represents the log messages related to the ESP coprocessor. + /// + public const string Esp = "esp"; } private readonly LogProviderCollection _providers = new(); @@ -44,7 +49,12 @@ public static class MessageGroup /// /// To show message from all groups, either use `MessageGroup.All` or clear the ShowsGroups list /// - public List ShowGroups { get; } = new(); + public List GroupsToShow { get; } = new(); + + /// + /// Gets or sets a value indicating whether to show message groups in log messages + /// + public bool ShowGroup { get; set; } = true; /// /// Gets or sets a value indicating whether to show ticks in log messages @@ -62,7 +72,7 @@ public static class MessageGroup /// A collection of providers to add to the Logger public Logger(params ILogProvider[] providers) { - ShowGroups.Add(MessageGroup.Application); + GroupsToShow.Add(MessageGroup.Application); foreach (var p in providers) { @@ -220,10 +230,10 @@ private void Log(LogLevel level, string message, string? messageGroup) if (messageGroup == null) messageGroup = MessageGroup.Application; - if (ShowGroups.Count > 0) + if (GroupsToShow.Count > 0) { - if (!ShowGroups.Contains(MessageGroup.All) - && !ShowGroups.Contains(messageGroup)) + if (!GroupsToShow.Contains(MessageGroup.All) + && !GroupsToShow.Contains(messageGroup)) { return; } @@ -238,11 +248,16 @@ private void Log(LogLevel level, string message, string? messageGroup) now = TimeSpan.FromMilliseconds(Environment.TickCount - _startupTicks); } + if (ShowGroup && messageGroup != null) + { + message = $"[{messageGroup}] {message}"; + } + foreach (var p in _providers) { if (now != null) { - message = $"[+{now:h\\:m\\:ss\\.FFF}] {message}"; + message = $"[+{now:hh\\:mm\\:ss\\.FFF}] {message}"; } p.Log(level, message, messageGroup);