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

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

#1 separate example code and doxygen comment and fix logging push logic by vfire

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