Skip to content

Commit

Permalink
Merge pull request #54 from WildernessLabs/v1.12.8
Browse files Browse the repository at this point in the history
Release 1.12.8
  • Loading branch information
jorgedevs authored Jul 12, 2024
2 parents 3b26ab1 + e71c351 commit 84d84e5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/develop-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Develop Build
on:
workflow_dispatch:
pull_request:
branches: [ develop ]
push:
branches: [ develop ]

Expand All @@ -16,12 +17,12 @@ jobs:
- name: Checkout Meadow.Logging
uses: actions/checkout@v3
with:
ref: develop
path: Meadow.Logging

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
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
5 changes: 3 additions & 2 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Main Build
on:
workflow_dispatch:
pull_request:
branches: [ main ]
push:
branches: [ main ]

Expand All @@ -16,12 +17,12 @@ jobs:
- name: Checkout Meadow.Logging
uses: actions/checkout@v3
with:
ref: main
path: Meadow.Logging

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Meadow.Core\source\implementations\f7\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\..\..\..\Meadow.Core\Source\implementations\f7\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\Driver\Meadow.Logging.LogProviders.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Meadow.Core\source\implementations\f7\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\..\..\..\Meadow.Core\Source\implementations\f7\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\Driver\Meadow.Logging.LogProviders.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Meadow.Core\source\implementations\f7\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\..\..\..\Meadow.Core\Source\implementations\f7\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\Driver\Meadow.Logging.LogProviders.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
27 changes: 21 additions & 6 deletions Source/Meadow.Logging/lib/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public static class MessageGroup
/// Represents the application-specific log messages.
/// </summary>
public const string Application = "application";

/// <summary>
/// Represents the log messages related to the ESP coprocessor.
/// </summary>
public const string Esp = "esp";
}

private readonly LogProviderCollection _providers = new();
Expand All @@ -44,7 +49,12 @@ public static class MessageGroup
/// <remarks>
/// To show message from all groups, either use `MessageGroup.All` <i>or</i> clear the ShowsGroups list
/// </remarks>
public List<string> ShowGroups { get; } = new();
public List<string> GroupsToShow { get; } = new();

/// <summary>
/// Gets or sets a value indicating whether to show message groups in log messages
/// </summary>
public bool ShowGroup { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether to show ticks in log messages
Expand All @@ -62,7 +72,7 @@ public static class MessageGroup
/// <param name="providers">A collection of providers to add to the Logger</param>
public Logger(params ILogProvider[] providers)
{
ShowGroups.Add(MessageGroup.Application);
GroupsToShow.Add(MessageGroup.Application);

foreach (var p in providers)
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down

0 comments on commit 84d84e5

Please sign in to comment.