Skip to content

Commit

Permalink
Merge pull request #3610 from chocolatey/hotfix/2.4.2
Browse files Browse the repository at this point in the history
(release) Chocolatey CLI 2.4.2
  • Loading branch information
AdmiringWorm authored Jan 29, 2025
2 parents b41f97f + 0cd5ffd commit c6e2f21
Show file tree
Hide file tree
Showing 2 changed files with 26 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 @@ -145,7 +145,23 @@ private static void Main(string[] args)
var traceAppenderName = "{0}LoggingColoredConsoleAppender".FormatWith(ChocolateyLoggers.Trace.ToStringSafe());
Log4NetAppenderConfiguration.EnableDebugLoggingIf(config.Debug, verboseAppenderName, traceAppenderName);
Log4NetAppenderConfiguration.EnableVerboseLoggingIf(config.Verbose, config.Debug, verboseAppenderName);
Log4NetAppenderConfiguration.EnableTraceLoggingIf(config.Trace, traceAppenderName);

if (config.Information.IsProcessElevated)
{
Log4NetAppenderConfiguration.EnableTraceLoggingIf(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}".FormatWith(ApplicationParameters.Name, config.Information.PlatformType, config.Information.PlatformVersion.ToStringSafe()));
//"chocolatey".Log().Debug(() => "Command Line: {0}".FormatWith(Environment.CommandLine));

Expand Down
10 changes: 9 additions & 1 deletion src/chocolatey/GetChocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,15 @@ private T EnsureOriginalConfiguration<T>(IList<string> args, Func<ChocolateyConf
var traceAppenderName = "{0}LoggingColoredConsoleAppender".FormatWith(ChocolateyLoggers.Trace.ToStringSafe());
Log4NetAppenderConfiguration.EnableDebugLoggingIf(configuration.Debug, verboseAppenderName, traceAppenderName);
Log4NetAppenderConfiguration.EnableVerboseLoggingIf(configuration.Verbose, configuration.Debug, verboseAppenderName);
Log4NetAppenderConfiguration.EnableTraceLoggingIf(configuration.Trace, traceAppenderName);

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 c6e2f21

Please sign in to comment.