From 862eecbc098dafb87a319dd8ba3753cf954d68e9 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Tue, 6 Jun 2017 13:52:52 -0500 Subject: [PATCH] (GH-976) Use Write-FunctionCallLogMessage Use Write-FunctionCallLogMessage instead of calling debug write - this allows additions to the function calls to be logged. Following on caa385036ea6cfafcecc37cdf39c0be25a5e10e2, it appears a few functions were missed. Switch those and log functions that should not implement the logging call. --- .../helpers/functions/Install-ChocolateyPath.ps1 | 4 +++- .../helpers/functions/Install-ChocolateyPinnedTaskBarItem.ps1 | 4 ++-- .../helpers/functions/Install-ChocolateyPowershellCommand.ps1 | 3 ++- .../helpers/functions/Install-ChocolateyShortcut.ps1 | 2 +- .../helpers/functions/Install-ChocolateyVsixPackage.ps1 | 3 ++- .../helpers/functions/Test-ProcessAdminRights.ps1 | 2 ++ .../helpers/functions/Write-FunctionCallLogMessage.ps1 | 3 +++ 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPath.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPath.ps1 index 39bec513a2..211b574fda 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPath.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPath.ps1 @@ -71,7 +71,9 @@ param( [parameter(Mandatory=$false, Position=1)][System.EnvironmentVariableTarget] $pathType = [System.EnvironmentVariableTarget]::User, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) - Write-Debug "Running 'Install-ChocolateyPath' with pathToInstall:`'$pathToInstall`'"; + + Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters + $originalPathToInstall = $pathToInstall #get the PATH variable diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPinnedTaskBarItem.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPinnedTaskBarItem.ps1 index d7d9da72e1..c3670574d9 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPinnedTaskBarItem.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPinnedTaskBarItem.ps1 @@ -52,8 +52,8 @@ param( [parameter(ValueFromRemainingArguments = $true)][Object[]]$ignoredArguments ) - Write-Debug "Running 'Install-ChocolateyPinnedTaskBarItem' with targetFilePath:`'$targetFilePath`'"; - + Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters + try{ if (test-path($targetFilePath)) { $verb = "Pin To Taskbar" diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPowershellCommand.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPowershellCommand.ps1 index 796184245a..816c60f93e 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPowershellCommand.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPowershellCommand.ps1 @@ -189,7 +189,8 @@ param( [parameter(Mandatory=$false)][hashtable] $options = @{Headers=@{}}, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) - Write-Debug "Running 'Install-ChocolateyPowershellCommand' for $packageName with psFileFullPath:`'$psFileFullPath`', url: `'$url`', url64bit:`'$url64bit`', checkSum: `'$checksum`', checksumType: `'$checksumType`', checkSum64: `'$checksum64`', checksumType64: `'$checksumType64`' "; + + Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters if ($url -ne '') { Get-ChocolateyWebFile $packageName $psFileFullPath $url $url64bit -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64 -Options $options diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyShortcut.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyShortcut.ps1 index 53eff1e584..c97a8e677b 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyShortcut.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyShortcut.ps1 @@ -129,7 +129,7 @@ Install-ChocolateyPinnedTaskBarItem [parameter(ValueFromRemainingArguments = $true)][Object[]]$ignoredArguments ) - Write-Debug "Running 'Install-ChocolateyShortcut' with parameters ShortcutFilePath: `'$shortcutFilePath`', TargetPath: `'$targetPath`', WorkingDirectory: `'$workingDirectory`', Arguments: `'$arguments`', IconLocation: `'$iconLocation`', Description: `'$description`', WindowStyle: `'$windowStyle`', RunAsAdmin: `'$runAsAdmin`', PinToTaskbar: `'$pinToTaskbar`'"; + Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters # http://powershell.com/cs/blogs/tips/archive/2009/02/05/validating-a-url.aspx function isURIWeb($address) { diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyVsixPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyVsixPackage.ps1 index 2e1f7bc239..f37e28134f 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyVsixPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyVsixPackage.ps1 @@ -146,7 +146,8 @@ param( [parameter(Mandatory=$false)][hashtable] $options = @{Headers=@{}}, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) - Write-Debug "Running 'Install-ChocolateyVsixPackage' for $packageName with vsixUrl:`'$vsixUrl`', vsVersion: `'$vsVersion`', checksum: `'$checksum`', checksumType: `'$checksumType`' "; + + Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters if($vsVersion -eq 0) { if ([System.IntPtr]::Size -eq 4) { diff --git a/src/chocolatey.resources/helpers/functions/Test-ProcessAdminRights.ps1 b/src/chocolatey.resources/helpers/functions/Test-ProcessAdminRights.ps1 index 85717495ac..a4479a86f7 100644 --- a/src/chocolatey.resources/helpers/functions/Test-ProcessAdminRights.ps1 +++ b/src/chocolatey.resources/helpers/functions/Test-ProcessAdminRights.ps1 @@ -36,6 +36,8 @@ None System.Boolean #> + # do not log function call + $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent([Security.Principal.TokenAccessLevels]'Query,Duplicate')) $isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) Write-Debug "Test-ProcessAdminRights: returning $isAdmin" diff --git a/src/chocolatey.resources/helpers/functions/Write-FunctionCallLogMessage.ps1 b/src/chocolatey.resources/helpers/functions/Write-FunctionCallLogMessage.ps1 index 79969388a7..43dcb202b1 100644 --- a/src/chocolatey.resources/helpers/functions/Write-FunctionCallLogMessage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Write-FunctionCallLogMessage.ps1 @@ -53,6 +53,9 @@ param ( $parameters, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) + + # do not log function call - recursion? + $argumentsPassed = '' foreach ($param in $parameters.GetEnumerator()) { if ($param.Key -eq 'ignoredArguments') { continue; }