Skip to content

Commit

Permalink
Fixed Logging API in CLI (#695)
Browse files Browse the repository at this point in the history
The issue was that methods that only receive a message were treating it
as format and would then report an error if the message contained a '{'
  • Loading branch information
igor84 authored Jan 30, 2025
1 parent 5764d44 commit 81dc663
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/NuGetForUnity.Cli/Fakes/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,43 @@ internal static void LogFormat(string format, params object[] args)
Console.WriteLine(format, args);
}

internal static void Log(string format, params object[] args)
internal static void Log(string message)
{
Console.WriteLine(format, args);
Console.WriteLine(message);
}

internal static void LogWarning(string format, params object[] args)
internal static void LogWarning(string message)
{
var oldForegroundColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(format, args);
Console.WriteLine(message);
Console.ForegroundColor = oldForegroundColor;
}

internal static void LogWarningFormat(string format, params object[] args)
{
var oldForegroundColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(format, args);
Console.ForegroundColor = oldForegroundColor;
}

internal static void LogError(string format, params object[] args)
internal static void LogError(string message)
{
HasError = true;
Console.Error.WriteLine(format, args);
var oldForegroundColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.Error.WriteLine(message);
Console.ForegroundColor = oldForegroundColor;
}

internal static void LogException(Exception e)
{
HasError = true;
var oldForegroundColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.Error.WriteLine(e.ToString());
Console.ForegroundColor = oldForegroundColor;
}

[Conditional("DEBUG")]
Expand Down

0 comments on commit 81dc663

Please sign in to comment.