Skip to content

Commit

Permalink
Merge pull request #1583 from gep13/issue-1580
Browse files Browse the repository at this point in the history
(GH-1580) Only output log messages when RegularOutput is enabled
  • Loading branch information
ferventcoder authored Mar 11, 2019
2 parents c449adc + dbb3629 commit 2706413
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright © 2017 - 2018 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
//
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright © 2017 - 2018 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
//
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -183,8 +183,8 @@ public void should_not_call_command_executor()
c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()),
Times.Never);
}
}
}

public class when_package_is_missing : AutomaticUninstallerServiceSpecsBase
{
public override void Context()
Expand Down Expand Up @@ -310,8 +310,8 @@ public void should_call_command_executor()
c => c.execute(expectedUninstallString, args, It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()),
Times.Once);
}
}
}

public class when_uninstall_string_is_empty : AutomaticUninstallerServiceSpecsBase
{
public override void Context()
Expand Down Expand Up @@ -379,8 +379,8 @@ public void should_not_call_command_executor()
c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()),
Times.Never);
}
}
}

public class when_registry_location_and_install_location_both_do_not_exist : AutomaticUninstallerServiceSpecsBase
{
public override void Context()
Expand Down Expand Up @@ -472,7 +472,7 @@ public void should_call_command_executor()
Times.Once);
}
}

public class when_uninstall_string_is_split_by_quotes : AutomaticUninstallerServiceSpecsBase
{
private readonly string uninstallStringWithQuoteSeparation = @"""C:\Program Files (x86)\WinDirStat\Uninstall.exe"" ""WinDir Stat""";
Expand Down Expand Up @@ -519,8 +519,8 @@ public void should_call_command_executor()
It.IsAny<bool>()),
Times.Once);
}
}
}

public class when_uninstall_string_has_ampersand_quot : AutomaticUninstallerServiceSpecsBase
{
private readonly string uninstallStringWithAmpersandQuot = @"&quot;C:\Program Files (x86)\WinDirStat\Uninstall.exe&quot; /SILENT";
Expand Down Expand Up @@ -568,8 +568,8 @@ public void should_call_command_executor()
It.IsAny<bool>()),
Times.Once);
}
}
}

public class when_uninstall_string_has_multiple_file_paths : AutomaticUninstallerServiceSpecsBase
{
private readonly string uninstallStringPointingToPath = @"C:\Programs\WinDirStat\Uninstall.exe D:\Programs\WinDirStat";
Expand Down Expand Up @@ -714,8 +714,8 @@ public void should_call_command_executor_appending_passed_arguments()
It.IsAny<bool>()),
Times.Once);
}
}
}

public class when_AutomaticUninstallerService_is_passed_overriding_uninstall_arguments_from_command_line : AutomaticUninstallerServiceSpecsBase
{
IInstaller _installerType = new InnoSetupInstaller();
Expand Down Expand Up @@ -822,7 +822,7 @@ private void test_installertype(IInstaller installer, bool hasQuietUninstallStri
//public void should_use_CustomInstaller_uninstall_args_when_installtype_is_unknown_and_has_quiet_uninstall_is_false()
//{
// test_installertype(new CustomInstaller(), hasQuietUninstallString: false);
//}
//}

[Fact]
public void should_use_registry_uninstall_args_when_installtype_is_unknown_and_has_quiet_uninstall_is_true()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright © 2017 - 2018 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
//
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -109,8 +109,8 @@ choco pin [list]|add|remove [<options/switches>]

"chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples");
"chocolatey".Log().Info(@"
choco pin
choco pin list
choco pin
choco pin list
choco pin add -n=git
choco pin add -n=git --version 1.2.3
choco pin remove --name git
Expand All @@ -128,7 +128,7 @@ public virtual void noop(ChocolateyConfiguration configuration)
public virtual void run(ChocolateyConfiguration configuration)
{
var packageManager = NugetCommon.GetPackageManager(configuration, _nugetLogger,
new PackageDownloader(),
new PackageDownloader(),
installSuccessAction: null,
uninstallSuccessAction: null,
addUninstallHandler: false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright © 2017 - 2018 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
//
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -121,7 +121,7 @@ public void remove(RegistryApplicationKey key, ChocolateyConfiguration config, P
if (!string.IsNullOrWhiteSpace(userProvidedUninstallArguments)) this.Log().Debug(ChocolateyLoggers.Verbose, " Using user passed {2}uninstaller args for {0}:'{1}'".format_with(package.Id, userProvidedUninstallArguments.escape_curly_braces(), userOverrideUninstallArguments ? "overriding " : string.Empty));
}
}

//todo: if there is a local package, look to use it in the future
if (string.IsNullOrWhiteSpace(key.UninstallString))
{
Expand Down Expand Up @@ -294,7 +294,7 @@ public virtual IInstaller get_installer_type(RegistryApplicationKey key, string
installer = new InstallShieldInstaller();
break;
}

return installer;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ namespace chocolatey.infrastructure.app.services
using System;
using System.IO;
using System.Text;
using configuration;
using NuGet;
using domain;
using infrastructure.configuration;
using tolerance;
using IFileSystem = filesystem.IFileSystem;

Expand All @@ -29,6 +31,7 @@ public class ChocolateyPackageInformationService : IChocolateyPackageInformation
private readonly IFileSystem _fileSystem;
private readonly IRegistryService _registryService;
private readonly IFilesService _filesService;
private readonly ChocolateyConfiguration _config;
private const string REGISTRY_SNAPSHOT_FILE = ".registry";
private const string REGISTRY_SNAPSHOT_BAD_FILE = ".registry.bad";
private const string FILES_SNAPSHOT_FILE = ".files";
Expand All @@ -44,14 +47,23 @@ public ChocolateyPackageInformationService(IFileSystem fileSystem, IRegistryServ
_fileSystem = fileSystem;
_registryService = registryService;
_filesService = filesService;
_config = Config.get_configuration_settings();
}

public ChocolateyPackageInformationService(IFileSystem fileSystem, IRegistryService registryService, IFilesService filesService, ChocolateyConfiguration config)
{
_fileSystem = fileSystem;
_registryService = registryService;
_filesService = filesService;
_config = config;
}

public ChocolateyPackageInformation get_package_information(IPackage package)
{
var packageInformation = new ChocolateyPackageInformation(package);
if (package == null)
{
this.Log().Debug("No package information as package is null.");
if (_config.RegularOutput) { this.Log().Debug("No package information as package is null."); }
return packageInformation;
}

Expand Down Expand Up @@ -79,7 +91,7 @@ focus exclusively in the string values not surrounded by CData. Once
{
if (_fileSystem.file_exists(_fileSystem.combine_paths(pkgStorePath, REGISTRY_SNAPSHOT_BAD_FILE)))
{
this.Log().Warn(deserializationErrorMessage);
if(_config.RegularOutput) { this.Log().Warn(deserializationErrorMessage); }
}
else
{
Expand All @@ -91,7 +103,7 @@ focus exclusively in the string values not surrounded by CData. Once
FaultTolerance.try_catch_with_logging_exception(
() =>
{
this.Log().Warn(deserializationErrorMessage);
if(_config.RegularOutput) { this.Log().Warn(deserializationErrorMessage); }

// rename the bad registry file so that it isn't processed again
_fileSystem.move_file(_fileSystem.combine_paths(pkgStorePath, REGISTRY_SNAPSHOT_FILE), _fileSystem.combine_paths(pkgStorePath, REGISTRY_SNAPSHOT_BAD_FILE));
Expand Down Expand Up @@ -147,7 +159,7 @@ public void save_package_information(ChocolateyPackageInformation packageInforma

if (packageInformation.Package == null)
{
this.Log().Debug("No package information to save as package is null.");
if(_config.RegularOutput) { this.Log().Debug("No package information to save as package is null."); }
return;
}

Expand Down Expand Up @@ -231,6 +243,7 @@ public void save_package_information(ChocolateyPackageInformation packageInforma
public void remove_package_information(IPackage package)
{
var pkgStorePath = _fileSystem.combine_paths(ApplicationParameters.ChocolateyPackageInfoStoreLocation, "{0}.{1}".format_with(package.Id, package.Version.to_string()));
if (_config.RegularOutput) { this.Log().Info("Removing Package Information for {0}".format_with(pkgStorePath)); }
_fileSystem.delete_directory_if_exists(pkgStorePath, recursive: true);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright © 2017 - 2018 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
//
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down

0 comments on commit 2706413

Please sign in to comment.