views:

15

answers:

1

Sometimes I don't want to break on reaching a line. I just want a message to be printed. Let's call it a logpoint by analogy with breakpoints.

I want an output format similar to this:

[Debugging] Foo.PerformCycle(): 15
[Debugging] Button.Repaint(): 1

Meaning that first I hit a logpoint on line 15 of method Foo.PerformCycle(), then I hit a logpoint on line 1 of Button.Repaint().

I don't want to write the "Console.WriteLine" code manually everytime. I want to go to the place, press a shortcut (similar to the breakpoint one, F9), and have the place be marked as a logpoint.

I would also settle for a Debug.LogHere() sort of function that I call and it automatically knows the current method and line to print.

+2  A: 

Right click on a breakpoint and select "When Hit..."

Select Print a message, and edit the message as needed (note the text which explains how to include the value of variables). Ensure Continue Execution is selected (otherwise the debugger will break).

This changes the break point into a "trace point" with a diamond (rather than circle) icon.

Richard