Skip to content

Commit

Permalink
(chocolateyGH-8) escape curly braces for log formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ferventcoder committed Jan 3, 2016
1 parent dbf0d22 commit 5fe4880
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ private PowerShellExecutionResults run_host(ChocolateyConfiguration config, stri
{
while (reader.Count > 0)
{
host.UI.WriteLine(reader.Read().to_string());
host.UI.WriteLine(reader.Read().to_string().escape_curly_braces());
}
}
};
Expand All @@ -439,7 +439,7 @@ private PowerShellExecutionResults run_host(ChocolateyConfiguration config, stri
{
while (reader.Count > 0)
{
host.UI.WriteErrorLine(reader.Read().to_string());
host.UI.WriteErrorLine(reader.Read().to_string().escape_curly_braces());
}
}
};
Expand Down
22 changes: 9 additions & 13 deletions src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override string ReadLine()

public override void Write(string value)
{
this.Log().Info(value);
this.Log().Info(value.escape_curly_braces());
//Console.Write(value);
}

Expand All @@ -74,9 +74,7 @@ public override void Write(ConsoleColor foregroundColor, ConsoleColor background
System.Console.ForegroundColor = foregroundColor;
System.Console.BackgroundColor = backgroundColor;

this.Log().Info(value);

//Console.Write(value);
this.Log().Info(value.escape_curly_braces());

System.Console.ForegroundColor = originalForegroundColor;
System.Console.BackgroundColor = originalBackgroundColor;
Expand All @@ -94,23 +92,21 @@ public override void WriteLine(ConsoleColor foregroundColor, ConsoleColor backgr
System.Console.ForegroundColor = foregroundColor;
System.Console.BackgroundColor = backgroundColor;

this.Log().Info(value);

//Console.Write(value);
this.Log().Info(value.escape_curly_braces());

System.Console.ForegroundColor = originalForegroundColor;
System.Console.BackgroundColor = originalBackgroundColor;
}

public override void WriteLine(string value)
{
this.Log().Info(value);
this.Log().Info(value.escape_curly_braces());
}

public override void WriteErrorLine(string value)
{
StandardErrorWritten = true;
this.Log().Error(value);
this.Log().Error(value.escape_curly_braces());
}

public override void WriteDebugLine(string message)
Expand All @@ -127,7 +123,7 @@ public override void WriteProgress(long sourceId, ProgressRecord record)
if (!hasLoggedStartProgress)
{
hasLoggedStartProgress = true;
this.Log().Debug(record.Activity);
this.Log().Debug(record.Activity.escape_curly_braces());
}

// http://stackoverflow.com/a/888569/18475
Expand All @@ -143,12 +139,12 @@ public override void WriteProgress(long sourceId, ProgressRecord record)

public override void WriteVerboseLine(string message)
{
this.Log().Info(ChocolateyLoggers.Verbose, "VERBOSE: " + message);
this.Log().Info(ChocolateyLoggers.Verbose, "VERBOSE: " + message.escape_curly_braces());
}

public override void WriteWarningLine(string message)
{
this.Log().Warn("WARNING: " + message);
this.Log().Warn("WARNING: " + message.escape_curly_braces());
}

public override Dictionary<string, PSObject> Prompt(string caption, string message, Collection<FieldDescription> descriptions)
Expand Down Expand Up @@ -201,7 +197,7 @@ private static string[] get_hotkey_and_label(string input)

public override int PromptForChoice(string caption, string message, Collection<ChoiceDescription> choices, int defaultChoice)
{
this.Log().Warn(caption);
this.Log().Warn(caption.escape_curly_braces());

string[,] promptData = build_hotkeys_and_plain_labels(choices);

Expand Down

0 comments on commit 5fe4880

Please sign in to comment.