I've introduced a logging facility; the goodies are in the Inkscape::Debug namespace.
Set the INKSCAPE_DEBUG_LOG environment variable to a filename, and Inkscape will write a structured XML outline of its activities there.
You can take advantage of this when debugging your own code. For example, if you want to highlight the changes that happen during a function, you add this to the top:
Debug::EventTrackerDebug::SimpleEvent tracker("my-func");
(if the function isn't inside the ::Inkscape namespace, you'll need to fully-qualify the type names)
After you recompile, any (logged) events that happen during a call to your function will appear grouped under a <my-func> tag in the log.
For example:
<my-func> <set-attribute node="element(0x8956a218)=svg:g(#g123)" name="foo" value="bar"/> </my-func>
(How it works: the <my-func> tag is written from the EventTracker's constructor, and </my-func> is written from its destructor when it goes out of scope.)
If you want to log fancier stuff (e.g. taking advantage of attributes) you'll currently need to write your own subclass of Debug::Event and use that instead of Debug::SimpleEvent.
Note that EventTracker will not create a Debug::Event object unless the log is turned on, so you don't pay a performance penalty when you're not using it.
See src/xml/simple-node.cpp for some examples (which are sadly probably more complicated than they need to be).
-mental
participants (1)
-
MenTaLguY