Vscode-powershell: Logpoints

Created on 13 Jul 2018  路  13Comments  路  Source: PowerShell/vscode-powershell

I did not see an open or closed issue related to the newer VS Code Logpoint feature so I thought I'd add one.

Having the ability to have specific log output to console without needing to write the code directly through the Logpoint functionality would be useful for debug purposes.

Area-Debugging Issue-Enhancement Up-for-Grabs

Most helpful comment

It would appear that I used the wrong quotes 馃槄

https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices/Services/DebugAdapter/Debugging/BreakpointApiUtils.cs#L180

Can you open an issue for supporting interpolation @rkeithhill?

Or perhaps a PR 馃檹

All 13 comments

Looks like the feature for VSCode is here.

@General-Gouda would you be able to give a small motivating example?

I have started work on this but got side-tracked. We already support a form Logpoints way before VSCode added the concept. Take a look at the Tracepoints section of this blog post - https://blogs.technet.microsoft.com/heyscriptingguy/2017/02/06/debugging-powershell-script-in-visual-studio-code-part-1/

BTW this issue should probably be logged in https://github.com/powershell/powershelleditorservices since all the work needs to be done there.

@rjmholt I do a lot of work with Active Directory and with Exchange Online. Many of the cmdlets do not return any console output and so I need to inject some sort of output to know what user I'm iterating through. Or, I will simply output the index number.

Since VS Code doesn't (yet) support Write-Progress I could see where outputting the index number through logpoints would be helpful rather than killing kittens with a Write-Host or something. It would also keep the code cleaner. I don't always need output on a saved script. Sometimes I just want to know it worked the first time I wrote it and then save it for later.

@rkeithhill I'll give tracepoints a try the next time I write a script like this. One point of feedback is that tracepoints appear to need more complex expressions. Is it possible to simply output a variable's value by typing in "$var" as the expression or does it have to be contained in a logic statement such as IF?

tracepoints appear to need more complex expressions

Agreed, Keep in mind the trace points implementation is just using Set-PSBreakpoint -Line xx -Action {}. That is, you can get the same functionality with raw PowerShell.

Implementing logpoints, will take an expression like this $var and integrate it into an Action like so: { <script to execute>; continue } e.g. {$var; continue}.

This is supported now 馃帀

How does this work? I tried with the Examples folder DebugTest.ps1 file. I set up a Log Point message of i is $i on line 12 and the $i is not interpolated. Neither is i is {$i}. How do you specify a variable so that its value will be logged?

It would appear that I used the wrong quotes 馃槄

https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices/Services/DebugAdapter/Debugging/BreakpointApiUtils.cs#L180

Can you open an issue for supporting interpolation @rkeithhill?

Or perhaps a PR 馃檹

I'll do that tonight, if you can wait.

Issue submitted #2654

I'll see if I can get a PR in here on my lunch break.

Bah, should have submitted that issue to PSES. Can you move it or should we leave it where it is?

It's ok where it is :)

Was this page helpful?
0 / 5 - 0 ratings