1

I found this trick and I like the idea of having the ability to have blocks of code run only in a debug configuration, but when I tried using it I ended up with a lot of lines looking like this:

if __debug__: logging.debug('started some work')

Sadly, it clutters the code significantly.
VS Code's logpoints are much more elegant way to do it, but I couldn't find a way to check them into version control, nor find how they are saved.
Is it possible to somehow share VS Code's breakpoints/logpoints with others?

Harvastum
  • 61
  • 10
  • Using `__debug__` and `logging.debug` is somewhat redundant. – Klaus D. Sep 24 '20 at 09:42
  • How so? The point of `if __debug__:` is to remove the block that follows from production code. I believe `logging.debug` is still present in the bytecode even if the logger has a different logging level enabled. Am I wrong? – Harvastum Sep 24 '20 at 10:28
  • 1
    breakpoints are placed by line number, if you pull and merge from team members and you open your project the breakpoints can be placed on the wrong lines – rioV8 Sep 24 '20 at 10:55
  • @Harvastum Can you tell us if my answer solved your question and which of the three suggested methods works for you? – Carlo Zanocco Sep 25 '20 at 16:45

1 Answers1

1

The only way that I know to archive something similar to share the breakpoints is to create a collaborative debug session. Take a look here, I have found relevant information:

Each collaborator can investigate different variables, jump to different files in the call stack, inspect variables, and even add or remove breakpoints. Co-editing features then allow each participant orator to track where the others are located to provide the unique ability to seamlessly switch between concurrently investigating different aspects of the problem and collaboratively debugging.

Using it is simple.

  1. Be sure both the host and all guests have the appropriate debugging extension installed. (Technically this is not always necessary, but it is generally a good idea.)

  2. As the host, if not already set up for the project, you should configure launch.json to debug the application from VS Code as you would normally. No special setup is required.

  3. Next, the host can start debugging using the button in the debug tab as normal.

You can easily setup what you need following the official guide


In case you want another alternative take a look at this extension, I have never tested it but it seems what you need.


Someone has created an issue on GitHub for this, but it seems to be dead.

Carlo Zanocco
  • 1,967
  • 4
  • 18
  • 31