Skip to content

Logpoints #1434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
General-Gouda opened this issue Jul 13, 2018 · 13 comments
Closed

Logpoints #1434

General-Gouda opened this issue Jul 13, 2018 · 13 comments
Assignees
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs.

Comments

@General-Gouda
Copy link

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.

@rjmholt rjmholt added the Issue-Enhancement A feature request (enhancement). label Jul 13, 2018
@rjmholt
Copy link
Contributor

rjmholt commented Jul 13, 2018

Looks like the feature for VSCode is here.

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

@rkeithhill
Copy link
Contributor

rkeithhill commented Jul 13, 2018

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.

@rkeithhill rkeithhill self-assigned this Jul 14, 2018
@General-Gouda
Copy link
Author

General-Gouda commented Jul 18, 2018

@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?

@rkeithhill
Copy link
Contributor

rkeithhill commented Jul 18, 2018

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}.

@TylerLeonhardt
Copy link
Member

This is supported now 🎉

@rkeithhill
Copy link
Contributor

rkeithhill commented Apr 22, 2020

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?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 22, 2020
@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Apr 22, 2020

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 🙏

@rkeithhill
Copy link
Contributor

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

@rkeithhill
Copy link
Contributor

Issue submitted #2654

@rkeithhill
Copy link
Contributor

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

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 22, 2020
@rkeithhill
Copy link
Contributor

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

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 22, 2020
@rkeithhill
Copy link
Contributor

PR submitted - PowerShell/PowerShellEditorServices#1270

@TylerLeonhardt
Copy link
Member

It's ok where it is :)

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs.
Projects
None yet
Development

No branches or pull requests

4 participants