Example/Tutorial on using FreeCad logging from C++

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
CandL
Posts: 85
Joined: Thu Oct 29, 2020 6:41 pm

Example/Tutorial on using FreeCad logging from C++

Post by CandL »

I am trying to debug some C++ in the Path workbench.

I would like to be able to write to the FreeCad log file written to C:\Users\***\AppData\Roaming\FreeCAD using the command line: FreeCADCmd.exe -l --run-test 0

I think I want to use the Macros in Console.h, Are there examples/tutorials on using these?

What does not seem to work is:

Code: Select all

#include <Base/Console.h> 

Then in a method:
     FC_MSG("Path Command Obj init")
Sorry for all the noob questions but there is a lot to take in
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Example/Tutorial on using FreeCad logging from C++

Post by wandererfan »

CandL wrote: Sat Aug 06, 2022 5:47 pm FC_MSG("Path Command Obj init")
I think FC_MSG writes to the report view. You probably want FC_LOG to write to the log. If that doesn't do it, try something like this:

Code: Select all

Base::Console().Log("myObject: %s  myLabel: %s\n", getNameInDocument(), Label.getValue());
CandL
Posts: 85
Joined: Thu Oct 29, 2020 6:41 pm

Re: Example/Tutorial on using FreeCad logging from C++

Post by CandL »

That did it ... Thanks
Post Reply