Idiom for logging in C++ code

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
marthinwurer
Posts: 24
Joined: Thu Sep 06, 2018 10:29 am

Idiom for logging in C++ code

Post by marthinwurer »

I'm trying to modify some of the BSpline code, and I want to log some data to help me. I tried using a basic printf, but that didn't work. What is the correct idiom for logging data from C++ code?

Edit: printf did work, my code wasn't being called. I'd still like to know the correct way to do logging from C++, though.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Idiom for logging in C++ code

Post by openBrain »

You can include <Base/Console.h> then use eg the FC_LOG() macro. ;)
marthinwurer
Posts: 24
Joined: Thu Sep 06, 2018 10:29 am

Re: Idiom for logging in C++ code

Post by marthinwurer »

Thanks! I'll use that instead.

I'll ask another question here to keep from spamming the board with new threads:

I'm working on implementing the functionality to have a B-Spline interpolated through user-defined points, like I asked about here. OpenCASCADE has the GeomAPI_Interpolate class that I should be able to use to generate the curve from a list of points. I'm looking at how the geometry is being created, and it looks like we send the parameters from the C++ code in CommandCreateGeo.cpp to python code which calls back into the C++ code in Sketch.cpp. Here's an example of where this is done. Why is this done in such a roundabout manner instead of just calling the C++ code directly?
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Idiom for logging in C++ code

Post by openBrain »

My guess is that it's done this way for macro recording purpose. ;)
Post Reply