Skip to content

Commit

Permalink
MaskSecrets -> Redact
Browse files Browse the repository at this point in the history
  • Loading branch information
timrogers committed Nov 10, 2023
1 parent 1f43610 commit 393f771
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Octoshift/Services/OctoLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public OctoLogger(Action<string> writeToLog, Action<string> writeToVerboseLog, A
private void Log(string msg, string level)
{
var output = FormatMessage(msg, level);
output = MaskSecrets(output);
output = Redact(output);
if (level == LogLevel.ERROR)
{
_writeToConsoleError(output);
Expand All @@ -84,7 +84,7 @@ private string FormatMessage(string msg, string level)
return $"[{timeFormat}] [{level}] {msg}\n";
}

private string MaskSecrets(string msg)
private string Redact(string msg)
{
var result = msg;

Expand Down Expand Up @@ -128,14 +128,14 @@ public virtual void LogError(Exception ex)
var verboseMessage = ex is HttpRequestException httpEx ? $"[HTTP ERROR {(int?)httpEx.StatusCode}] {ex}" : ex.ToString();
var logMessage = Verbose ? verboseMessage : ex is OctoshiftCliException ? ex.Message : GENERIC_ERROR_MESSAGE;

var output = MaskSecrets(FormatMessage(logMessage, LogLevel.ERROR));
var output = Redact(FormatMessage(logMessage, LogLevel.ERROR));

Console.ForegroundColor = ConsoleColor.Red;
_writeToConsoleError(output);
Console.ResetColor();

_writeToLog(output);
_writeToVerboseLog(MaskSecrets(FormatMessage(verboseMessage, LogLevel.ERROR)));
_writeToVerboseLog(Redact(FormatMessage(verboseMessage, LogLevel.ERROR)));
}

public virtual void LogVerbose(string msg)
Expand All @@ -148,7 +148,7 @@ public virtual void LogVerbose(string msg)
}
else
{
_writeToVerboseLog(MaskSecrets(FormatMessage(msg, LogLevel.VERBOSE)));
_writeToVerboseLog(Redact(FormatMessage(msg, LogLevel.VERBOSE)));
}
}

Expand Down

0 comments on commit 393f771

Please sign in to comment.