source: libcf/trunk/include/cf_log.h@ 38

Last change on this file since 38 was 38, checked in by cheese, 11 years ago

#1 modify test.c for more detail test of multi-threaded logging

File size: 2.8 KB
Line 
1/**
2 * @file cf_log.h
3 * @author myusgun <myusgun@gmail.com>
4 * @version 0.1
5 *
6 * @example log.c
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
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
25/**
26 * 로그의 버퍼 크기를 기본 값으로 설정
27 *
28 * @see CF_Log_CreateCtx, CF_LOG_OPEN
29 */
30#define CF_LOG_BUFFER_DEFAULT -1
31
32/**
33 * 로그 기록 시 버퍼를 사용하지 않고 즉시 기록
34 *
35 * @see CF_Log_CreateCtx, CF_LOG_OPEN, CF_Log_Initialize
36 */
37#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/** 로그 컨텍스트 */
75typedef void * CF_Log_Ctx;
76
77#ifdef __cplusplus
78extern "C" {
79#endif
80
81CF_EXPORT int
82CF_Log_Initialize (const int logPool);
83
84CF_EXPORT int
85CF_Log_Finalize (void);
86
87CF_EXPORT CF_Log_Ctx
88CF_Log_CreateCtx (const char * path,
89 const int memsize);
90
91CF_EXPORT int
92CF_Log_DestroyCtx (CF_Log_Ctx ctx);
93
94CF_EXPORT int
95CF_Log_SetMultiThread (CF_Log_Ctx ctx);
96
97CF_EXPORT int
98CF_Log_UnsetMultiThread (CF_Log_Ctx ctx);
99
100CF_EXPORT int
101CF_Log_Write (CF_Log_Ctx ctx,
102 const char * prefix,
103 const char * fmt, ...);
104
105CF_EXPORT int
106CF_Log_Flush (CF_Log_Ctx ctx);
107
108CF_EXPORT int
109CF_Log_MapCtxID (const int mapid,
110 const CF_Log_Ctx ctx);
111
112CF_EXPORT int
113CF_Log_UnmapCtxID (const int mapid);
114
115CF_EXPORT CF_Log_Ctx
116CF_Log_GetMappedCtx (const int mapid);
117
118#ifdef __cplusplus
119}
120#endif
121
122#endif // #ifndef __CF_LOG_H__
Note: See TracBrowser for help on using the repository browser.