Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#933) Remove duplicate output from console and Chocolatey GUI logs #954

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 9 additions & 25 deletions Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ public async Task<PackageOperationResult> InstallPackage(
using (await Lock.WriteLockAsync())
{
var logger = new SerilogLogger(Logger, _progressService);
var choco = Lets.GetChocolatey(initializeLogging: false).SetCustomLogging(logger, logExistingMessages: false, addToExistingLoggers: true);
choco.Set(
_choco.Set(
config =>
{
config.CommandName = CommandNameType.install.ToString();
config.PackageNames = id;
config.Features.UsePackageExitCodes = false;
config.Verbose = true;

if (version != null)
{
Expand Down Expand Up @@ -238,22 +238,7 @@ public async Task<PackageOperationResult> InstallPackage(
config.DownloadChecksumType64 = advancedInstallOptions.DownloadChecksumType64bit;
}
});

Action<LogMessage> grabErrors;
var errors = GetErrors(out grabErrors);

using (logger.Intercept(grabErrors))
{
await choco.RunAsync();

if (Environment.ExitCode != 0)
{
Environment.ExitCode = 0;
return new PackageOperationResult { Successful = false, Messages = errors.ToArray() };
}

return PackageOperationResult.SuccessfulCached;
}
return await RunCommand(_choco, logger);
}
}

Expand Down Expand Up @@ -351,21 +336,21 @@ public async Task<PackageOperationResult> UninstallPackage(string id, string ver
using (await Lock.WriteLockAsync())
{
var logger = new SerilogLogger(Logger, _progressService);
var choco = Lets.GetChocolatey(initializeLogging: false).SetCustomLogging(logger, logExistingMessages: false, addToExistingLoggers: true);
choco.Set(
_choco.Set(
config =>
{
config.CommandName = CommandNameType.uninstall.ToString();
config.PackageNames = id;
config.Features.UsePackageExitCodes = false;
config.Verbose = true;

if (version != null)
{
config.Version = version.ToString();
}
});

return await RunCommand(choco, logger);
return await RunCommand(_choco, logger);
}
}

Expand All @@ -374,16 +359,15 @@ public async Task<PackageOperationResult> UpdatePackage(string id, Uri source =
using (await Lock.WriteLockAsync())
{
var logger = new SerilogLogger(Logger, _progressService);
var choco = Lets.GetChocolatey(initializeLogging: false).SetCustomLogging(logger, logExistingMessages: false, addToExistingLoggers: true);
choco.Set(
_choco.Set(
config =>
{
config.CommandName = CommandNameType.upgrade.ToString();
config.PackageNames = id;
config.Features.UsePackageExitCodes = false;
config.Verbose = true;
});

return await RunCommand(choco, logger);
return await RunCommand(_choco, logger);
}
}

Expand Down