1 | /**
|
---|
2 | * cf_log.h
|
---|
3 | */
|
---|
4 | #ifndef __CF_LOG_H__
|
---|
5 | #define __CF_LOG_H__
|
---|
6 |
|
---|
7 | #include "cf_base.h"
|
---|
8 |
|
---|
9 | #define CF_ERROR_LOG_INITIALIZE CF_ERROR_LOG - 1
|
---|
10 | #define CF_ERROR_LOG_INVALID_CTX CF_ERROR_LOG - 2
|
---|
11 | #define CF_ERROR_LOG_SET_MULTITHREAD CF_ERROR_LOG - 3
|
---|
12 | #define CF_ERROR_LOG_UNSET_MULTITHREAD CF_ERROR_LOG - 4
|
---|
13 | #define CF_ERROR_LOG_LOCK_CTX CF_ERROR_LOG - 5
|
---|
14 | #define CF_ERROR_LOG_UNLOCK_CTX CF_ERROR_LOG - 6
|
---|
15 | #define CF_ERROR_LOG_FLUSH CF_ERROR_LOG - 7
|
---|
16 | #define CF_ERROR_LOG_INVALID_MAPID CF_ERROR_LOG - 8
|
---|
17 | #define CF_ERROR_LOG_NOT_MAPPED_ID CF_ERROR_LOG - 9
|
---|
18 | #define CF_ERROR_LOG_ALREADY_MAPPED_ID CF_ERROR_LOG - 10
|
---|
19 | #define CF_ERROR_LOG_NOT_INITIALIZE CF_ERROR_LOG - 11
|
---|
20 |
|
---|
21 | #define CF_LOG_BUFFER_DEFAULT -1
|
---|
22 | #define CF_LOG_BUFFER_NO 0
|
---|
23 |
|
---|
24 | #define CF_LOG_OPEN(__id,__file,__memsize) \
|
---|
25 | CF_Log_MapCtxID (__id, CF_Log_CreateCtx (__file, __memsize))
|
---|
26 |
|
---|
27 | #define CF_LOG_WRITE(__id,__pf,__fmt,...) \
|
---|
28 | CF_Log_Write (CF_Log_GetMappedCtx (__id),__pf,__fmt,##__VA_ARGS__)
|
---|
29 |
|
---|
30 | #define CF_LOG_CLOSE CF_Log_UnmapCtxID
|
---|
31 |
|
---|
32 | typedef void * CF_Log_Ctx;
|
---|
33 |
|
---|
34 | #ifdef __cplusplus
|
---|
35 | extern "C" {
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | CF_EXPORT int
|
---|
39 | CF_Log_Initialize (const int logPool);
|
---|
40 |
|
---|
41 | CF_EXPORT int
|
---|
42 | CF_Log_Finalize (void);
|
---|
43 |
|
---|
44 | CF_EXPORT CF_Log_Ctx
|
---|
45 | CF_Log_CreateCtx (const char * path,
|
---|
46 | const int memsize);
|
---|
47 |
|
---|
48 | CF_EXPORT int
|
---|
49 | CF_Log_DestroyCtx (CF_Log_Ctx ctx);
|
---|
50 |
|
---|
51 | CF_EXPORT int
|
---|
52 | CF_Log_SetMultiThread (CF_Log_Ctx ctx);
|
---|
53 |
|
---|
54 | CF_EXPORT int
|
---|
55 | CF_Log_UnsetMultiThread (CF_Log_Ctx ctx);
|
---|
56 |
|
---|
57 | CF_EXPORT int
|
---|
58 | CF_Log_Write (CF_Log_Ctx ctx,
|
---|
59 | const char * prefix,
|
---|
60 | const char * fmt, ...);
|
---|
61 |
|
---|
62 | CF_EXPORT int
|
---|
63 | CF_Log_Flush (CF_Log_Ctx ctx);
|
---|
64 |
|
---|
65 | CF_EXPORT int
|
---|
66 | CF_Log_MapCtxID (const int mapid,
|
---|
67 | const CF_Log_Ctx ctx);
|
---|
68 |
|
---|
69 | CF_EXPORT int
|
---|
70 | CF_Log_UnmapCtxID (const int mapid);
|
---|
71 |
|
---|
72 | CF_EXPORT CF_Log_Ctx
|
---|
73 | CF_Log_GetMappedCtx (const int mapid);
|
---|
74 |
|
---|
75 | #ifdef __cplusplus
|
---|
76 | }
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | #endif // #ifndef __CF_LOG_H__
|
---|