/** * @file debug.c * @author myusgun * @version 0.1 */ #include "cf_file.h" #include "cf_debug.h" CF_Debug_Ctx gDebugCtx; void callee (void) { CF_Debug_CallStack callstack; CF_DEBUG_CALLSTACK_PUSH (gDebugCtx); CF_DEBUG_CALLSTACK_POP (gDebugCtx, &callstack); } int main (void) { int fd = 0; gDebugCtx = CF_Debug_CreateCtx (); CF_DEBUG_CALLSTACK_PUSH (gDebugCtx); CF_DEBUG_TRACE (gDebugCtx, "print trace message with context to stderr\n"); fd = CF_File_Create ("debug.txt"); if (fd < 0) { CF_DEBUG_PRINT (stderr, "error ...\n"); // error } CF_Debug_SetOutputFD (gDebugCtx, fd); CF_DEBUG_TRACE (gDebugCtx, "print trace message with context to debug.txt\n"); CF_DEBUG_CALLSTACK_POP (gDebugCtx, NULL); CF_Debug_DestroyCtx (gDebugCtx); return 0; }