Skip to content

Commit

Permalink
Universal Output wasn't actually universal (#8072)
Browse files Browse the repository at this point in the history
* change the addition of consoles so that on universal output, stuff really doesn't make it to stderr
* finally fix the weirdness with the loglevel
  • Loading branch information
scbedd authored Apr 17, 2024
1 parent 5bac009 commit 93565cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static RootCommand GenerateCommandLineOptions(Func<DefaultOptions, Task>
dumpOption.AddAlias("-d");

var universalOption = new Option<bool>(
name: "--universalOutput",
name: "--universal",
description: "Flag; Redirect all logs to stdout, including what would normally be showing up on stderr.",
getDefaultValue: () => false);
universalOption.AddAlias("-u");
Expand Down Expand Up @@ -83,6 +83,7 @@ public static RootCommand GenerateCommandLineOptions(Func<DefaultOptions, Task>
var startCommand = new Command("start", "Start the TestProxy.");
startCommand.AddOption(insecureOption);
startCommand.AddOption(dumpOption);
startCommand.AddOption(universalOption);
startCommand.AddArgument(collectedArgs);

startCommand.SetHandler(async (startOpts) => await callback(startOpts),
Expand Down
10 changes: 7 additions & 3 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,14 @@ private static void StartServer(StartOptions startOptions)
{
loggingBuilder.ClearProviders();
loggingBuilder.AddConfiguration(hostBuilder.Configuration.GetSection("Logging"));
loggingBuilder.AddConsole(options =>
if (!startOptions.UniversalOutput)
{
options.LogToStandardErrorThreshold = startOptions.UniversalOutput ? LogLevel.None : LogLevel.Error;
}).AddSimpleConsole(options =>
loggingBuilder.AddConsole(options =>
{
options.LogToStandardErrorThreshold = LogLevel.Error;
});
}
loggingBuilder.AddSimpleConsole(options =>
{
options.TimestampFormat = "[HH:mm:ss] ";
});
Expand Down

0 comments on commit 93565cb

Please sign in to comment.