Skip to content

Commit

Permalink
Merge pull request #3611 from chocolatey/hotfix/1.4.2
Browse files Browse the repository at this point in the history
(release) Chocolatey CLI 1.4.2
  • Loading branch information
AdmiringWorm authored Jan 29, 2025
2 parents 3fa34f8 + d658139 commit ccdfbee
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,23 @@ private static void Main(string[] args)
var traceAppenderName = "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Trace.to_string());
Log4NetAppenderConfiguration.set_logging_level_debug_when_debug(config.Debug, verboseAppenderName, traceAppenderName);
Log4NetAppenderConfiguration.set_verbose_logger_when_verbose(config.Verbose, config.Debug, verboseAppenderName);
Log4NetAppenderConfiguration.set_trace_logger_when_trace(config.Trace, traceAppenderName);

if (config.Information.IsProcessElevated)
{
Log4NetAppenderConfiguration.set_trace_logger_when_trace(config.Trace, traceAppenderName);
}
else
{
var logger = ChocolateyLoggers.Normal;

if (!config.RegularOutput)
{
logger = ChocolateyLoggers.LogFileOnly;
}

"chocolatey".Log().Warn(logger, "Usage of the --trace option is only allowed when running from an elevated session.");
}

"chocolatey".Log().Debug(() => "{0} is running on {1} v {2}".format_with(ApplicationParameters.Name, config.Information.PlatformType, config.Information.PlatformVersion.to_string()));
//"chocolatey".Log().Debug(() => "Command Line: {0}".format_with(Environment.CommandLine));

Expand Down
17 changes: 16 additions & 1 deletion src/chocolatey/GetChocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,22 @@ private T ensure_original_configuration<T>(IList<string> args, Func<ChocolateyCo
var traceAppenderName = "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Trace.to_string());
Log4NetAppenderConfiguration.set_logging_level_debug_when_debug(configuration.Debug, verboseAppenderName, traceAppenderName);
Log4NetAppenderConfiguration.set_verbose_logger_when_verbose(configuration.Verbose, configuration.Debug, verboseAppenderName);
Log4NetAppenderConfiguration.set_trace_logger_when_trace(configuration.Trace, traceAppenderName);

if (configuration.Information.IsProcessElevated)
{
Log4NetAppenderConfiguration.set_trace_logger_when_trace(configuration.Trace, traceAppenderName);
}
else
{
var logger = ChocolateyLoggers.Normal;

if (!configuration.RegularOutput)
{
logger = ChocolateyLoggers.LogFileOnly;
}

"chocolatey".Log().Warn(logger, "Usage of the --trace option is only allowed when running from an elevated session.");
}
}
finally
{
Expand Down

0 comments on commit ccdfbee

Please sign in to comment.