[23] | 1 | /**
|
---|
[26] | 2 | * @file cf_log.h
|
---|
| 3 | * @author myusgun <myusgun@gmail.com>
|
---|
| 4 | * @version 0.1
|
---|
[34] | 5 | *
|
---|
[35] | 6 | * @example log.c
|
---|
[11] | 7 | */
|
---|
| 8 | #ifndef __CF_LOG_H__
|
---|
| 9 | #define __CF_LOG_H__
|
---|
| 10 |
|
---|
| 11 | #include "cf_base.h"
|
---|
| 12 |
|
---|
| 13 | #define CF_ERROR_LOG_INITIALIZE CF_ERROR_LOG - 1
|
---|
[12] | 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
|
---|
[19] | 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
|
---|
[11] | 24 |
|
---|
[26] | 25 | /**
|
---|
| 26 | * 로그의 버퍼 크기를 기본 값으로 설정
|
---|
| 27 | *
|
---|
| 28 | * @see CF_Log_CreateCtx, CF_LOG_OPEN
|
---|
| 29 | */
|
---|
[12] | 30 | #define CF_LOG_BUFFER_DEFAULT -1
|
---|
[26] | 31 |
|
---|
| 32 | /** 로그 기록 시 버퍼를 사용하지 않고 즉시 기록
|
---|
| 33 | *
|
---|
| 34 | * @see CF_Log_CreateCtx, CF_LOG_OPEN, CF_Log_Initialize
|
---|
| 35 | */
|
---|
[12] | 36 | #define CF_LOG_BUFFER_NO 0
|
---|
[11] | 37 |
|
---|
[26] | 38 | /**
|
---|
| 39 | * 로그에 아이디 넘버를 부여하여 생성 <br />
|
---|
| 40 | * 로그 기록 시, 아이디 넘버를 사용하면 해당 로그로 기록할 수 있음
|
---|
| 41 | *
|
---|
| 42 | * @param __id 부여할 아이디 넘버
|
---|
| 43 | * @param __file 로그 파일 경로
|
---|
| 44 | * @param __memsize 로그 버퍼 크기
|
---|
| 45 | *
|
---|
| 46 | * @see CF_Log_MapCtxID
|
---|
| 47 | */
|
---|
[19] | 48 | #define CF_LOG_OPEN(__id,__file,__memsize) \
|
---|
| 49 | CF_Log_MapCtxID (__id, CF_Log_CreateCtx (__file, __memsize))
|
---|
| 50 |
|
---|
[26] | 51 | /**
|
---|
| 52 | * 아이디 넘버에 해당하는 로그에 쓰기
|
---|
| 53 | *
|
---|
| 54 | * @param __id 로그의 아이디 넘버
|
---|
| 55 | * @param __pf 로그의 프리픽스 문자열
|
---|
| 56 | * @param __fmt 포맷 스트링
|
---|
| 57 | * @param ... 가변 인자
|
---|
| 58 | *
|
---|
| 59 | * @see CF_Log_GetMappedCtx
|
---|
| 60 | */
|
---|
[19] | 61 | #define CF_LOG_WRITE(__id,__pf,__fmt,...) \
|
---|
| 62 | CF_Log_Write (CF_Log_GetMappedCtx (__id),__pf,__fmt,##__VA_ARGS__)
|
---|
| 63 |
|
---|
[26] | 64 | /**
|
---|
| 65 | * 아이디 넘버에 해당하는 로그를 닫고 해제
|
---|
| 66 | *
|
---|
| 67 | * @param __id 로그의 아이디 넘버
|
---|
| 68 | *
|
---|
| 69 | * @see CF_Log_UnmapCtxID
|
---|
| 70 | */
|
---|
| 71 | #define CF_LOG_CLOSE(__id) CF_Log_UnmapCtxID (__id)
|
---|
[19] | 72 |
|
---|
[26] | 73 | /** 로그 컨텍스트 */
|
---|
[11] | 74 | typedef void * CF_Log_Ctx;
|
---|
| 75 |
|
---|
| 76 | #ifdef __cplusplus
|
---|
| 77 | extern "C" {
|
---|
| 78 | #endif
|
---|
| 79 |
|
---|
| 80 | CF_EXPORT int
|
---|
[12] | 81 | CF_Log_Initialize (const int logPool);
|
---|
[11] | 82 |
|
---|
| 83 | CF_EXPORT int
|
---|
| 84 | CF_Log_Finalize (void);
|
---|
| 85 |
|
---|
[12] | 86 | CF_EXPORT CF_Log_Ctx
|
---|
| 87 | CF_Log_CreateCtx (const char * path,
|
---|
| 88 | const int memsize);
|
---|
| 89 |
|
---|
[11] | 90 | CF_EXPORT int
|
---|
[19] | 91 | CF_Log_DestroyCtx (CF_Log_Ctx ctx);
|
---|
| 92 |
|
---|
| 93 | CF_EXPORT int
|
---|
[12] | 94 | CF_Log_SetMultiThread (CF_Log_Ctx ctx);
|
---|
[11] | 95 |
|
---|
[12] | 96 | CF_EXPORT int
|
---|
| 97 | CF_Log_UnsetMultiThread (CF_Log_Ctx ctx);
|
---|
| 98 |
|
---|
| 99 | CF_EXPORT int
|
---|
| 100 | CF_Log_Write (CF_Log_Ctx ctx,
|
---|
| 101 | const char * prefix,
|
---|
| 102 | const char * fmt, ...);
|
---|
| 103 |
|
---|
| 104 | CF_EXPORT int
|
---|
| 105 | CF_Log_Flush (CF_Log_Ctx ctx);
|
---|
| 106 |
|
---|
[19] | 107 | CF_EXPORT int
|
---|
| 108 | CF_Log_MapCtxID (const int mapid,
|
---|
| 109 | const CF_Log_Ctx ctx);
|
---|
| 110 |
|
---|
| 111 | CF_EXPORT int
|
---|
| 112 | CF_Log_UnmapCtxID (const int mapid);
|
---|
| 113 |
|
---|
| 114 | CF_EXPORT CF_Log_Ctx
|
---|
| 115 | CF_Log_GetMappedCtx (const int mapid);
|
---|
| 116 |
|
---|
[11] | 117 | #ifdef __cplusplus
|
---|
| 118 | }
|
---|
| 119 | #endif
|
---|
| 120 |
|
---|
| 121 | #endif // #ifndef __CF_LOG_H__
|
---|