00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PJ_LOG_H__
00021 #define __PJ_LOG_H__
00022
00028 #include <pj/types.h>
00029 #include <stdarg.h>
00030
00031 PJ_BEGIN_DECL
00032
00070 enum pj_log_decoration
00071 {
00072 PJ_LOG_HAS_DAY_NAME = 1,
00073 PJ_LOG_HAS_YEAR = 2,
00074 PJ_LOG_HAS_MONTH = 4,
00075 PJ_LOG_HAS_DAY_OF_MON = 8,
00076 PJ_LOG_HAS_TIME = 16,
00077 PJ_LOG_HAS_MICRO_SEC = 32,
00078 PJ_LOG_HAS_SENDER = 64,
00079 PJ_LOG_HAS_NEWLINE = 128,
00080 PJ_LOG_HAS_CR = 256,
00081 PJ_LOG_HAS_SPACE = 512,
00082 PJ_LOG_HAS_COLOR = 1024,
00083 PJ_LOG_HAS_LEVEL_TEXT = 2048,
00084 PJ_LOG_HAS_THREAD_ID = 4096,
00085 PJ_LOG_HAS_THREAD_SWC = 8192,
00086 PJ_LOG_HAS_INDENT =16384
00087 };
00088
00107 #define PJ_LOG(level,arg) do { \
00108 if (level <= pj_log_get_level()) \
00109 pj_log_wrapper_##level(arg); \
00110 } while (0)
00111
00120 typedef void pj_log_func(int level, const char *data, int len);
00121
00132 PJ_DECL(void) pj_log_write(int level, const char *buffer, int len);
00133
00134
00135 #if PJ_LOG_MAX_LEVEL >= 1
00136
00145 PJ_DECL(void) pj_log(const char *sender, int level,
00146 const char *format, va_list marker);
00147
00157 PJ_DECL(void) pj_log_set_log_func( pj_log_func *func );
00158
00164 PJ_DECL(pj_log_func*) pj_log_get_log_func(void);
00165
00176 PJ_DECL(void) pj_log_set_level(int level);
00177
00183 #if 1
00184 PJ_DECL(int) pj_log_get_level(void);
00185 #else
00186 PJ_DECL_DATA(int) pj_log_max_level;
00187 #define pj_log_get_level() pj_log_max_level
00188 #endif
00189
00199 PJ_DECL(void) pj_log_set_decor(unsigned decor);
00200
00206 PJ_DECL(unsigned) pj_log_get_decor(void);
00207
00216 PJ_DECL(void) pj_log_add_indent(int indent);
00217
00221 PJ_DECL(void) pj_log_push_indent(void);
00222
00226 PJ_DECL(void) pj_log_pop_indent(void);
00227
00234 PJ_DECL(void) pj_log_set_color(int level, pj_color_t color);
00235
00242 PJ_DECL(pj_color_t) pj_log_get_color(int level);
00243
00247 pj_status_t pj_log_init(void);
00248
00249 #else
00250
00260 # define pj_log_set_log_func(func)
00261
00272 # define pj_log_set_level(level)
00273
00283 # define pj_log_set_decor(decor)
00284
00291 # define pj_log_set_color(level, color)
00292
00298 # define pj_log_get_level() 0
00299
00305 # define pj_log_get_decor() 0
00306
00313 # define pj_log_get_color(level) 0
00314
00315
00319 # define pj_log_init() PJ_SUCCESS
00320
00321 #endif
00322
00327
00328
00329
00330
00331
00332
00333
00334
00341 #if PJ_LOG_MAX_LEVEL >= 1
00342 #define pj_log_wrapper_1(arg) pj_log_1 arg
00343
00344 PJ_DECL(void) pj_log_1(const char *src, const char *format, ...);
00345 #else
00346 #define pj_log_wrapper_1(arg)
00347 #endif
00348
00355 #if PJ_LOG_MAX_LEVEL >= 2
00356 #define pj_log_wrapper_2(arg) pj_log_2 arg
00357
00358 PJ_DECL(void) pj_log_2(const char *src, const char *format, ...);
00359 #else
00360 #define pj_log_wrapper_2(arg)
00361 #endif
00362
00369 #if PJ_LOG_MAX_LEVEL >= 3
00370 #define pj_log_wrapper_3(arg) pj_log_3 arg
00371
00372 PJ_DECL(void) pj_log_3(const char *src, const char *format, ...);
00373 #else
00374 #define pj_log_wrapper_3(arg)
00375 #endif
00376
00383 #if PJ_LOG_MAX_LEVEL >= 4
00384 #define pj_log_wrapper_4(arg) pj_log_4 arg
00385
00386 PJ_DECL(void) pj_log_4(const char *src, const char *format, ...);
00387 #else
00388 #define pj_log_wrapper_4(arg)
00389 #endif
00390
00397 #if PJ_LOG_MAX_LEVEL >= 5
00398 #define pj_log_wrapper_5(arg) pj_log_5 arg
00399
00400 PJ_DECL(void) pj_log_5(const char *src, const char *format, ...);
00401 #else
00402 #define pj_log_wrapper_5(arg)
00403 #endif
00404
00411 #if PJ_LOG_MAX_LEVEL >= 6
00412 #define pj_log_wrapper_6(arg) pj_log_6 arg
00413
00414 PJ_DECL(void) pj_log_6(const char *src, const char *format, ...);
00415 #else
00416 #define pj_log_wrapper_6(arg)
00417 #endif
00418
00419
00420 PJ_END_DECL
00421
00422 #endif
00423