Go to the documentation of this file.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 };
00086
00105 #define PJ_LOG(level,arg) do { \
00106 if (level <= pj_log_get_level()) \
00107 pj_log_wrapper_##level(arg); \
00108 } while (0)
00109
00118 typedef void pj_log_func(int level, const char *data, int len);
00119
00130 PJ_DECL(void) pj_log_write(int level, const char *buffer, int len);
00131
00132
00133 #if PJ_LOG_MAX_LEVEL >= 1
00134
00143 PJ_DECL(void) pj_log(const char *sender, int level,
00144 const char *format, va_list marker);
00145
00155 PJ_DECL(void) pj_log_set_log_func( pj_log_func *func );
00156
00162 PJ_DECL(pj_log_func*) pj_log_get_log_func(void);
00163
00174 PJ_DECL(void) pj_log_set_level(int level);
00175
00181 #if 1
00182 PJ_DECL(int) pj_log_get_level(void);
00183 #else
00184 PJ_DECL_DATA(int) pj_log_max_level;
00185 #define pj_log_get_level() pj_log_max_level
00186 #endif
00187
00197 PJ_DECL(void) pj_log_set_decor(unsigned decor);
00198
00204 PJ_DECL(unsigned) pj_log_get_decor(void);
00205
00206
00213 PJ_DECL(void) pj_log_set_color(int level, pj_color_t color);
00214
00221 PJ_DECL(pj_color_t) pj_log_get_color(int level);
00222
00226 pj_status_t pj_log_init(void);
00227
00228 #else
00229
00239 # define pj_log_set_log_func(func)
00240
00251 # define pj_log_set_level(level)
00252
00262 # define pj_log_set_decor(decor)
00263
00270 # define pj_log_set_color(level, color)
00271
00277 # define pj_log_get_level() 0
00278
00284 # define pj_log_get_decor() 0
00285
00292 # define pj_log_get_color(level) 0
00293
00294
00298 # define pj_log_init() PJ_SUCCESS
00299
00300 #endif
00301
00306
00307
00308
00309
00310
00311
00312
00313
00320 #if PJ_LOG_MAX_LEVEL >= 1
00321 #define pj_log_wrapper_1(arg) pj_log_1 arg
00322
00323 PJ_DECL(void) pj_log_1(const char *src, const char *format, ...);
00324 #else
00325 #define pj_log_wrapper_1(arg)
00326 #endif
00327
00334 #if PJ_LOG_MAX_LEVEL >= 2
00335 #define pj_log_wrapper_2(arg) pj_log_2 arg
00336
00337 PJ_DECL(void) pj_log_2(const char *src, const char *format, ...);
00338 #else
00339 #define pj_log_wrapper_2(arg)
00340 #endif
00341
00348 #if PJ_LOG_MAX_LEVEL >= 3
00349 #define pj_log_wrapper_3(arg) pj_log_3 arg
00350
00351 PJ_DECL(void) pj_log_3(const char *src, const char *format, ...);
00352 #else
00353 #define pj_log_wrapper_3(arg)
00354 #endif
00355
00362 #if PJ_LOG_MAX_LEVEL >= 4
00363 #define pj_log_wrapper_4(arg) pj_log_4 arg
00364
00365 PJ_DECL(void) pj_log_4(const char *src, const char *format, ...);
00366 #else
00367 #define pj_log_wrapper_4(arg)
00368 #endif
00369
00376 #if PJ_LOG_MAX_LEVEL >= 5
00377 #define pj_log_wrapper_5(arg) pj_log_5 arg
00378
00379 PJ_DECL(void) pj_log_5(const char *src, const char *format, ...);
00380 #else
00381 #define pj_log_wrapper_5(arg)
00382 #endif
00383
00390 #if PJ_LOG_MAX_LEVEL >= 6
00391 #define pj_log_wrapper_6(arg) pj_log_6 arg
00392
00393 PJ_DECL(void) pj_log_6(const char *src, const char *format, ...);
00394 #else
00395 #define pj_log_wrapper_6(arg)
00396 #endif
00397
00398
00399 PJ_END_DECL
00400
00401 #endif
00402