From Yefu's notes
Jump to: navigation, search

A simple logging class can be found at: http://ahm507.blogspot.com/2006/12/simplest-logging-class-in-c.html

However, what I need is something that can simply replace printf. I have some old codes full of printfs but in the new environment printing is not available. So I revise it to write to a file like this:

#define DEBUGP(x, ...) \
	FILE* debug_fp=fopen("debug.log","a"); \
	fseek(debug_fp, 0, SEEK_END); \
	fprintf(debug_fp, " [%s()+, %s:%u]" \
	x, __FILE__, __FUNCTION__ ,__LINE__, __VA_ARGS__);\