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