Changeset 40 in libcf for trunk/include/cf_log.h


Ignore:
Timestamp:
02/06/13 16:11:24 (11 years ago)
Author:
cheese
Message:

#1 change interface of log from context to id-number

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cf_log.h

    r38 r40  
    1111#include "cf_base.h"
    1212
    13 #define CF_ERROR_LOG_INITIALIZE         CF_ERROR_LOG - 1
    14 #define CF_ERROR_LOG_INVALID_CTX        CF_ERROR_LOG - 2
    15 #define CF_ERROR_LOG_SET_MULTITHREAD    CF_ERROR_LOG - 3
    16 #define CF_ERROR_LOG_UNSET_MULTITHREAD  CF_ERROR_LOG - 4
    17 #define CF_ERROR_LOG_LOCK_CTX           CF_ERROR_LOG - 5
    18 #define CF_ERROR_LOG_UNLOCK_CTX         CF_ERROR_LOG - 6
    19 #define CF_ERROR_LOG_FLUSH              CF_ERROR_LOG - 7
    20 #define CF_ERROR_LOG_INVALID_MAPID      CF_ERROR_LOG - 8
    21 #define CF_ERROR_LOG_NOT_MAPPED_ID      CF_ERROR_LOG - 9
    22 #define CF_ERROR_LOG_ALREADY_MAPPED_ID  CF_ERROR_LOG - 10
    23 #define CF_ERROR_LOG_NOT_INITIALIZE     CF_ERROR_LOG - 11
    24 
    2513/**
    2614 * 로그의 버퍼 크기를 기본 값으로 설정
    2715 *
    28  * @see CF_Log_CreateCtx, CF_LOG_OPEN
     16 * @see CF_Log_Open
    2917 */
    3018#define CF_LOG_BUFFER_DEFAULT           -1
     
    3321 * 로그 기록 시 버퍼를 사용하지 않고 즉시 기록
    3422 *
    35  * @see CF_Log_CreateCtx, CF_LOG_OPEN, CF_Log_Initialize
     23 * @see CF_Log_Open
    3624 */
    3725#define CF_LOG_BUFFER_NO                0
    38 
    39 /**
    40  * 로그에 아이디 넘버를 부여하여 생성 <br />
    41  * 로그 기록 시, 아이디 넘버를 사용하면 해당 로그로 기록할 수 있음
    42  *
    43  * @param __id      부여할 아이디 넘버
    44  * @param __file    로그 파일 경로
    45  * @param __memsize 로그 버퍼 크기
    46  *
    47  * @see CF_Log_MapCtxID
    48  */
    49 #define CF_LOG_OPEN(__id,__file,__memsize)              \
    50     CF_Log_MapCtxID (__id, CF_Log_CreateCtx (__file, __memsize))
    51 
    52 /**
    53  * 아이디 넘버에 해당하는 로그에 쓰기
    54  *
    55  * @param __id  로그의 아이디 넘버
    56  * @param __pf  로그의 프리픽스 문자열
    57  * @param __fmt 포맷 스트링
    58  * @param ...   가변 인자
    59  *
    60  * @see CF_Log_GetMappedCtx
    61  */
    62 #define CF_LOG_WRITE(__id,__pf,__fmt,...)               \
    63     CF_Log_Write (CF_Log_GetMappedCtx (__id),__pf,__fmt,##__VA_ARGS__)
    64 
    65 /**
    66  * 아이디 넘버에 해당하는 로그를 닫고 해제
    67  *
    68  * @param __id 로그의 아이디 넘버
    69  *
    70  * @see CF_Log_UnmapCtxID
    71  */
    72 #define CF_LOG_CLOSE(__id)      CF_Log_UnmapCtxID (__id)
    73 
    74 /** 로그 컨텍스트 */
    75 typedef void *  CF_Log_Ctx;
    7626
    7727#ifdef __cplusplus
     
    8535CF_Log_Finalize         (void);
    8636
    87 CF_EXPORT CF_Log_Ctx
    88 CF_Log_CreateCtx        (const char * path,
     37CF_EXPORT int
     38CF_Log_Open             (const int  mapid,
     39                         const char * path,
    8940                         const int  memsize);
    9041
    9142CF_EXPORT int
    92 CF_Log_DestroyCtx       (CF_Log_Ctx ctx);
     43CF_Log_Close            (const int mapid);
    9344
    9445CF_EXPORT int
    95 CF_Log_SetMultiThread   (CF_Log_Ctx ctx);
     46CF_Log_SetMT            (const int      mapid,
     47                         const CF_BOOL  flag);
    9648
    9749CF_EXPORT int
    98 CF_Log_UnsetMultiThread (CF_Log_Ctx ctx);
    99 
    100 CF_EXPORT int
    101 CF_Log_Write            (CF_Log_Ctx ctx,
     50CF_Log_Write            (const int  mapid,
    10251                         const char * prefix,
    10352                         const char * fmt, ...);
    10453
    10554CF_EXPORT int
    106 CF_Log_Flush            (CF_Log_Ctx ctx);
    107 
    108 CF_EXPORT int
    109 CF_Log_MapCtxID         (const int          mapid,
    110                          const CF_Log_Ctx   ctx);
    111 
    112 CF_EXPORT int
    113 CF_Log_UnmapCtxID       (const int mapid);
    114 
    115 CF_EXPORT CF_Log_Ctx
    116 CF_Log_GetMappedCtx     (const int mapid);
     55CF_Log_Flush            (const int mapid);
    11756
    11857#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.