Changeset 35 in libcf for trunk/include/cf_debug.h


Ignore:
Timestamp:
02/05/13 18:18:37 (11 years ago)
Author:
cheese
Message:

#1 separate example code and doxygen comment and fix logging push logic by vfire

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cf_debug.h

    r34 r35  
    1212 * (단, 콜스택의 푸시/팝은 컨텍스트를 이용해야만 사용 가능)
    1313 *
    14  * @section 샘플코드
    15  * @code
    16 
    17 #include "cf_debug.h"
    18 
    19 CF_Debug_Ctx gDebugCtx;
    20 
    21 void callee (void) {
    22     CF_Debug_CallStack callstack;
    23    
    24     CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
    25     CF_DEBUG_CALLSTACK_POP (gDebugCtx, &callstack);
    26 }
    27 
    28 int main (void) {
    29     int fd = 0;
    30     gDebugCtx = CF_Debug_CreateCtx ();
    31 
    32     CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
    33 
    34     CF_DEBUG_TRACE (gDebugCtx, "print trace message with context to stderr\n");
    35 
    36     fd = CF_File_Create ("debug.txt");
    37     if (fd < 0) {
    38         CF_DEBUG_PRINT (stderr, "error ...\n");
    39         // error
    40     }
    41     CF_Debug_SetOutputFD (gDebugCtx, fd);
    42 
    43     CF_DEBUG_TRACE (gDebugCtx, "print trace message with context to debug.txt\n");
    44 
    45     CF_DEBUG_CALLSTACK_POP (gDebugCtx, NULL);
    46 
    47     CF_Debug_DestroyCtx (gDebugCtx);
    48 
    49     return 0;
    50 }
    51 
    52  * @endcode
     14 * @example debug.c
    5315 */
    5416#ifndef __CF_DEBUG_H__
     
    186148#endif
    187149
    188 /**
    189  * 디버그 컨텍스트를 생성
    190  *
    191  * @return 성공 시, CF_Debug_Ctx 형태의 컨텍스트; 실패 시, NULL
    192  * @see CF_DEBUG_CREATE_CTX
    193  */
    194150CF_EXPORT CF_Debug_Ctx
    195151CF_Debug_CreateCtx      (void);
    196152
    197 /**
    198  * 디버그 컨텍스트를 해제
    199  *
    200  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    201  *
    202  * @param ctx 디버그 컨텍스트
    203  *
    204  * @see CF_DEBUG_DESTROY_CTX
    205  */
    206153CF_EXPORT int
    207154CF_Debug_DestroyCtx     (CF_Debug_Ctx ctx);
    208155
    209 /**
    210  * 디버그 컨텍스트에 출력할 파일 디스크립터를 설정
    211  *
    212  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    213  *
    214  * @param ctx   디버그 컨텍스트
    215  * @param fd    파일 디스크립터
    216  *
    217  * @see CF_File_Open, CF_File_Create
    218  */
    219156CF_EXPORT int
    220157CF_Debug_SetOutputFD    (CF_Debug_Ctx   ctx,
    221158                         int            fd);
    222159
    223 /**
    224  * 디버그 메시지를 지정된 파일 포인터로 출력
    225  *
    226  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    227  *
    228  * @param fp    파일 포인터. 표준출력(stdout) 및 표준오류(stderr) 사용 가능
    229  * @param file  파일 경로
    230  * @param func  함수 이름
    231  * @param line  라인 넘버
    232  * @param fmt   포맷 스트링
    233  * @param ...   가변 인자
    234  *
    235  * @see CF_DEBUG_PRINT
    236  */
    237160CF_EXPORT int
    238161CF_Debug_Print          (FILE       * fp,
     
    242165                         const char * fmt, ...);
    243166
    244 /**
    245  * 바이너리 데이터를 디버그 메시지와 함께 지정된 파일 포인터로 출력
    246  *
    247  * @return CF_OK 반환
    248  *
    249  * @param fp    파일 포인터. 표준출력(stdout) 및 표준오류(stderr) 사용 가능
    250  * @param file  파일 경로
    251  * @param func  함수 이름
    252  * @param line  라인 넘버
    253  * @param bin   라인 넘버
    254  * @param len   바이너리 길이
    255  * @param fmt   포맷 스트링
    256  * @param ...   가변 인자
    257  *
    258  * @see CF_DEBUG_PRINT_BIN
    259  */
    260167CF_EXPORT int
    261168CF_Debug_PrintBin       (FILE                   * fp,
     
    267174                         const char             * fmt, ...);
    268175
    269 /**
    270  * 컨텍스트를 업데이트하고 디버그 메시지를 출력
    271  *
    272  * @return CF_OK 반환
    273  *
    274  * @param ctx   디버그 컨텍스트
    275  * @param file  파일 경로
    276  * @param func  함수 이름
    277  * @param line  라인 넘버
    278  * @param fmt   포맷 스트링
    279  * @param ...   가변 인자
    280  *
    281  * @see CF_DEBUG_UPDATE_CTX, CF_Debug_Trace
    282  */
    283176CF_EXPORT int
    284177CF_Debug_Trace          (CF_Debug_Ctx   ctx,
     
    288181                         const char     * fmt, ...);
    289182
    290 /**
    291  * 컨텍스트를 업데이트하고 바이너리 데이터를 디버그 메시지와 함께 출력
    292  *
    293  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    294  *
    295  * @param ctx   디버그 컨텍스트
    296  * @param file  파일 경로
    297  * @param func  함수 이름
    298  * @param line  라인 넘버
    299  * @param bin   바이너리 데이터
    300  * @param len   바이너리 길이
    301  * @param fmt   포맷 스트링
    302  * @param ...   가변 인자
    303  *
    304  * @see CF_DEBUG_UPDATE_CTX, CF_DEBUG_TRACE_BIN
    305  */
    306183CF_EXPORT int
    307184CF_Debug_TraceBin       (CF_Debug_Ctx           ctx,
     
    313190                         const char             * fmt, ...);
    314191
    315 /**
    316  * 컨텍스트에 콜스택 푸시
    317  *
    318  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    319  *
    320  * @param ctx   디버그 컨텍스트
    321  * @param file  파일 경로
    322  * @param func  함수 이름
    323  * @param line  라인 넘버
    324  *
    325  * @see CF_DEBUG_CALLSTACK_PUSH
    326  */
    327192CF_EXPORT int
    328193CF_Debug_CallStackPush  (CF_Debug_Ctx   ctx,
     
    331196                         const int      line);
    332197
    333 /**
    334  * 컨텍스트에서 콜스택 팝
    335  *
    336  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    337  *
    338  * @param ctx       디버그 컨텍스트
    339  * @param callstack 콜스택 정보를 가져올 콜스택 데이터 구조체 포인터
    340  *
    341  * @see CF_Debug_CallStackPop, CF_Debug_CallStack
    342  */
    343198CF_EXPORT int
    344199CF_Debug_CallStackPop   (CF_Debug_Ctx       ctx,
Note: See TracChangeset for help on using the changeset viewer.