Skip to content

Commit

Permalink
Fix logging for GitHub Workflow command
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Oct 14, 2023
1 parent 59caf9d commit 1c2719e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/dotnet-releaser/Logging/ISimpleLogger.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
using DotNetReleaser.Helpers;
using Lunet.Extensions.Logging.SpectreConsole;
Expand Down Expand Up @@ -59,6 +60,7 @@ private class SimpleLoggerRedirect : ISimpleLogger
private readonly ILogger _log;
private int _logId;
private readonly bool _runningFromGitHubAction;
private static readonly Regex MatchGitHubWorkflowCommand = new("^::[a-z]+");

public SimpleLoggerRedirect(ILogger log)
{
Expand Down Expand Up @@ -94,6 +96,13 @@ public void LogEndGroup()

public void LogSimple(LogLevel level, Exception? exception, string? message, bool markup, params object?[] args)
{
if (message is not null && MatchGitHubWorkflowCommand.IsMatch(message))
{
AnsiConsole.WriteLine(message);
Console.Out.Flush();
return;
}

if (level == LogLevel.Error) HasErrors = true;
var id = Interlocked.Increment(ref _logId);
if (markup)
Expand Down

0 comments on commit 1c2719e

Please sign in to comment.