Skip to content

Commit

Permalink
(GH-976) Use Write-FunctionCallLogMessage
Browse files Browse the repository at this point in the history
Use Write-FunctionCallLogMessage instead of calling debug write - this
allows additions to the function calls to be logged. Following on
caa3850, it appears a few functions
were missed. Switch those and log functions that should not implement
the logging call.
  • Loading branch information
ferventcoder committed Jun 6, 2017
1 parent 1bcd6dc commit 862eecb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit 862eecb

Please sign in to comment.