For quick and dirty debugging in C I usually put together something like this : 
open file in append mode, write to file, close file.  (this way is the code 
crashes you still have something useful in your debug log).
Using C’s getenv allows the debug logging to be turned on/off with an 
environment variable at run time (no fancy config file parsing needed).

Here are some examples if you are new to C

https://www.tutorialspoint.com/c_standard_library/c_function_fprintf.htm
https://www.tutorialspoint.com/c_standard_library/c_function_getenv.htm
http://rosettacode.org/wiki/Category:C

And in the “more than you wanted to know” department (including xs tutorial, 
perl internals, and how to use gdb on perl)

http://perldoc.perl.org/perlhacktips.html
http://perldoc.perl.org/index-internals.html

Reply via email to