Debug Statements in Paraview

Hi, I am creating my own Filter, so I was wondering if there is a way to print Debug statements in between c++ code? So that when I load the plugin and apply my filter I can see those print statements?

use vtkWarningMacro if cout doesnt work for you.

1 Like

Okay, thanks!

I personally prefer vtkLog macros over vtkWarning..., discussed here. They make it a little easier to format the generated text, plus support different log levels too.

Also note, if trying to debug your filter in parallel, pvserver supports command line arguments that can save output logs to separate files per rank – thus avoid clobbering output from multiple ranks.

If I use vtkLog and use this command to run paraview, will these logs gets printed to the same paraview.log file?

paraview.exe -l=C:\Users\msaad\paraview.log,TRACE

Didn’t quite get you. I am uploading .dll file of my filter through Manage Plugin (for now) and then using my filter normally. I want to see the input and output data and other messages that I want to print for debugging.

Yes.

Since you’re not running a separate pvserver, you can ignore my comment. Essentially, similar to how you are doing paraview.exe -l=...paraview.log,TRACE, you can run a parallel pvserver as mpirun -np <num ranks> pvserver -l=...pvserver.log,TRACE and you’ll get log files names pvserver.0.log, pvserver.1.log, etc. for each pvserver process.

@utkarsh.ayachit : Afaik, vtkLog does not go to the output window, does it ?

Hmm, I can’t recall…it probably doesn’t. Note, the Log Viewer is probably more useful for such debugging anyways.

Logging to file is always a better option when developing a new filter, though; even if the application crashes, you have the logs saved out to a file to inspect and diagnose the issue.

1 Like

It does not.