Skip to content

Commit 00d919a

Browse files
committed
(#3622) Skip trace warning when trace not used
This updates the warning that is outputted in non-elevated mode to not be outputted when the user has not specified `--trace` on the commandline. Without this change, any time a use are running in a non-elevated mode, they will always have the trace warning outputted even when they haven't used the argument. (cherry picked from commit 3a0d4b6)
1 parent 8845afd commit 00d919a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/chocolatey.console/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private static void Main(string[] args)
150150
{
151151
Log4NetAppenderConfiguration.EnableTraceLoggingIf(config.Trace, traceAppenderName);
152152
}
153-
else
153+
else if (config.Trace)
154154
{
155155
var logger = ChocolateyLoggers.Normal;
156156

src/chocolatey/GetChocolatey.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,17 @@ private T EnsureOriginalConfiguration<T>(IList<string> args, Func<ChocolateyConf
449449
Log4NetAppenderConfiguration.EnableDebugLoggingIf(configuration.Debug, verboseAppenderName, traceAppenderName);
450450
Log4NetAppenderConfiguration.EnableVerboseLoggingIf(configuration.Verbose, configuration.Debug, verboseAppenderName);
451451

452-
var logger = ChocolateyLoggers.Normal;
453-
454-
if (!configuration.RegularOutput)
452+
if (!configuration.Information.IsProcessElevated && configuration.Trace)
455453
{
456-
logger = ChocolateyLoggers.LogFileOnly;
457-
}
454+
var logger = ChocolateyLoggers.Normal;
455+
456+
if (!configuration.RegularOutput)
457+
{
458+
logger = ChocolateyLoggers.LogFileOnly;
459+
}
458460

459-
"chocolatey".Log().Warn(logger, "Usage of the --trace option is only allowed when running from an elevated session.");
461+
"chocolatey".Log().Warn(logger, "Usage of the --trace option is only allowed when running from an elevated session.");
462+
}
460463
}
461464
finally
462465
{

0 commit comments

Comments
 (0)