From f4f0042a653217923a6142ca17a267136e3234d4 Mon Sep 17 00:00:00 2001 From: Dmitry Teselkin Date: Tue, 6 Aug 2013 17:21:18 +0400 Subject: [PATCH] Show-InvocationInfo added to Logger.ps1. This function helps to trace function calls. Change-Id: I4a8a2469c109747e32220f882bb88e73291a31e8 --- .../Modules/CoreFunctions/include/Logger.ps1 | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/WindowsPowerShell/Modules/CoreFunctions/include/Logger.ps1 b/WindowsPowerShell/Modules/CoreFunctions/include/Logger.ps1 index 9bcb6b75..9140c95a 100644 --- a/WindowsPowerShell/Modules/CoreFunctions/include/Logger.ps1 +++ b/WindowsPowerShell/Modules/CoreFunctions/include/Logger.ps1 @@ -134,4 +134,29 @@ New-Alias -Name Write-LogDebug -Value Out-LogDebug +function Show-InvocationInfo { + param ( + $Invocation, + [Switch] $End + ) + + if ($End) { + Write-LogDebug "" + } + else { + Write-LogDebug "" + Write-LogDebug "" + foreach ($Parameter in $Invocation.MyCommand.Parameters) { + foreach ($Key in $Parameter.Keys) { + $Type = $Parameter[$Key].ParameterType.FullName + foreach ($Value in $Invocation.BoundParameters[$Key]) { + Write-LogDebug "[$Type] $Key = '$Value'" + } + } + } + Write-LogDebug "" + } +} + + Initialize-Logger