Changeset 35 in libcf for trunk/include/cf_log.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_log.h

    r34 r35  
    44 * @version 0.1
    55 *
    6  * @section 샘플코드
    7  * @code
    8 
    9 #include "cf_log.h"
    10 
    11 CF_Log_Ctx gLogCtx;
    12 
    13 void main (const char * message)
    14 {
    15     int         i, j;
    16     char        logname[16] = {0x00,};
    17 
    18     CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
    19 
    20     CF_Log_Initialize (10);
    21 
    22     // with context
    23     gLogCtx = CF_Log_CreateCtx (file, CF_LOG_BUFFER_DEFAULT);
    24     if (gLogCtx == NULL)
    25         CF_DEBUG_PRINT (stderr, "create log ctx error\n");
    26 
    27     for (i = 0 ; i < 10000 ; i++)
    28         CF_Log_Write (gLogCtx, "LOG_TEST", "turn %d\n", i);
    29 
    30     CF_DEBUG_CALLSTACK_POP (gDebugCtx, &gDebugCallstack);
    31 
    32     CF_Log_Write (gLogCtx, message,
    33                             "here is the end of function [file:%s line:%d func:%s]\n",
    34                             gDebugCallstack.file,
    35                             gDebugCallstack.line,
    36                             gDebugCallstack.function);
    37 
    38     CF_Log_DestroyCtx (gLogCtx);
    39 
    40     // with id number
    41     for (i = 0 ; i < 10 ; i++)
    42     {
    43         sprintf (logname, "logid%d.txt", i);
    44         CF_LOG_OPEN (i, logname, CF_LOG_BUFFER_NO);
    45     }
    46 
    47     for (i = 0 ; i < 10 ; i++)
    48     {
    49         for (j = 0 ; j < 10000 ; j++)
    50             CF_LOG_WRITE (i, "LOG_ID_TEST", "turn %d\n", j);
    51 
    52         CF_LOG_CLOSE (i);
    53     }
    54 
    55     CF_Log_Finalize ();
    56 }
    57 
    58  * @endcode
     6 * @example log.c
    597 */
    608#ifndef __CF_LOG_H__
     
    13078#endif
    13179
    132 /**
    133  * 로그를 사용하기 위해 초기화
    134  *
    135  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    136  *
    137  * @param logPool 아이디 넘버 최대 값
    138  */
    13980CF_EXPORT int
    14081CF_Log_Initialize       (const int logPool);
    14182
    142 /**
    143  * 로그가 모두 사용된 후 자원 해제
    144  *
    145  * @return CF_OK 반환
    146  */
    14783CF_EXPORT int
    14884CF_Log_Finalize         (void);
    14985
    150 /**
    151  * 로그 컨텍스트 생성
    152  *
    153  * @return 성공 시, 로그 컨텍스트; 실패 시, NULL
    154  *
    155  * @param path      로그 파일 경로
    156  * @param memsize   로그 버퍼 크기
    157  *
    158  * @see CF_LOG_BUFFER_DEFAULT, CF_LOG_BUFFER_NO
    159  */
    16086CF_EXPORT CF_Log_Ctx
    16187CF_Log_CreateCtx        (const char * path,
    16288                         const int  memsize);
    16389
    164 /**
    165  * 로그 컨텍스트 해제
    166  *
    167  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    168  *
    169  * @param ctx 로그 컨텍스트
    170  */
    17190CF_EXPORT int
    17291CF_Log_DestroyCtx       (CF_Log_Ctx ctx);
    17392
    174 /**
    175  * 로그 컨텍스트에 멀티쓰레드 모드 설정
    176  *
    177  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    178  *
    179  * @param ctx 로그 컨텍스트
    180  */
    18193CF_EXPORT int
    18294CF_Log_SetMultiThread   (CF_Log_Ctx ctx);
    18395
    184 /**
    185  * 로그 컨텍스트에 멀티쓰레드 모드 설정 해제
    186  *
    187  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    188  *
    189  * @param ctx 로그 컨텍스트
    190  */
    19196CF_EXPORT int
    19297CF_Log_UnsetMultiThread (CF_Log_Ctx ctx);
    19398
    194 /**
    195  * 로그 컨텍스트에 따라 로그 쓰기
    196  *
    197  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    198  *
    199  * @param ctx       로그 컨텍스트
    200  * @param prefix    로그의 프리픽스 문자열
    201  * @param fmt       포맷 스트링
    202  * @param ...       가변 인자
    203  */
    20499CF_EXPORT int
    205100CF_Log_Write            (CF_Log_Ctx ctx,
     
    207102                         const char * fmt, ...);
    208103
    209 /**
    210  * 로그 버퍼의 데이터를 즉시 로그 파일에 쓰기
    211  *
    212  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    213  *
    214  * @param ctx 로그 컨텍스트
    215  */
    216104CF_EXPORT int
    217105CF_Log_Flush            (CF_Log_Ctx ctx);
    218106
    219 /**
    220  * 로그 컨텍스트에 아이디 넘버 할당<br />
    221  * 로그 기록 시, 아이디 넘버를 사용하면 해당 로그로 기록할 수 있음
    222  *
    223  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    224  *
    225  * @param mapid 부여할 아이디 넘버
    226  * @param ctx   로그 컨텍스트
    227  *
    228  * @remark 반드시 먼저 초기화 해야하며, 초기화 시에 주어진 번호보다 작은 아이디 넘버를 사용해야 함
    229  *
    230  * @see CF_LOG_OPEN, CF_Log_CreateCtx
    231  */
    232107CF_EXPORT int
    233108CF_Log_MapCtxID         (const int          mapid,
    234109                         const CF_Log_Ctx   ctx);
    235110
    236 /**
    237  * 아이디 넘버에 해당하는 로그를 닫고 해당하는 컨텍스트를 해제
    238  *
    239  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    240  *
    241  * @param mapid 로그의 아이디 넘버
    242  *
    243  * @remark 아이디 넘버에 해당하는 컨텍스트가 해제되므로 주의
    244  *
    245  * @see CF_LOG_CLOSE, CF_Log_DestroyCtx
    246  */
    247111CF_EXPORT int
    248112CF_Log_UnmapCtxID       (const int mapid);
    249113
    250 /**
    251  * 아이디 넘버에 해당하는 로그 컨텍스트를 얻기
    252  *
    253  * @return 성공 시, 로그 컨텍스트; 실패 시, NULL
    254  *
    255  * @param mapid 로그의 아이디 넘버
    256  */
    257114CF_EXPORT CF_Log_Ctx
    258115CF_Log_GetMappedCtx     (const int mapid);
Note: See TracChangeset for help on using the changeset viewer.