BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

log.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_LOG_H__
20#define __PJ_LOG_H__
21
27#include <pj/types.h>
28#include <stdarg.h>
29
31
70{
85 PJ_LOG_HAS_INDENT =16384
86};
87
106#define PJ_LOG(level,arg) do { \
107 if (level <= pj_log_get_level()) { \
108 pj_log_wrapper_##level(arg); \
109 } \
110 } while (0)
111
120typedef void pj_log_func(int level, const char *data, int len);
121
132PJ_DECL(void) pj_log_write(int level, const char *buffer, int len);
133
134
135#if PJ_LOG_MAX_LEVEL >= 1
136
145PJ_DECL(void) pj_log(const char *sender, int level,
146 const char *format, va_list marker);
147
157PJ_DECL(void) pj_log_set_log_func( pj_log_func *func );
158
165
176PJ_DECL(void) pj_log_set_level(int level);
177
183#if 1
184PJ_DECL(int) pj_log_get_level(void);
185#else
186PJ_DECL_DATA(int) pj_log_max_level;
187#define pj_log_get_level() pj_log_max_level
188#endif
189
199PJ_DECL(void) pj_log_set_decor(unsigned decor);
200
206PJ_DECL(unsigned) pj_log_get_decor(void);
207
216PJ_DECL(void) pj_log_add_indent(int indent);
217
223PJ_DECL(void) pj_log_set_indent(int indent);
224
230PJ_DECL(int) pj_log_get_indent(void);
231
235PJ_DECL(void) pj_log_push_indent(void);
236
240PJ_DECL(void) pj_log_pop_indent(void);
241
248PJ_DECL(void) pj_log_set_color(int level, pj_color_t color);
249
256PJ_DECL(pj_color_t) pj_log_get_color(int level);
257
262
263#else /* #if PJ_LOG_MAX_LEVEL >= 1 */
264
274# define pj_log_set_log_func(func)
275
284# define pj_log(sender, level, format, marker)
285
296# define pj_log_set_level(level)
297
307# define pj_log_set_decor(decor)
308
317# define pj_log_add_indent(indent)
318
324# define pj_log_set_indent(indent)
325
331# define pj_log_get_indent() 0
332
336# define pj_log_push_indent()
337
341# define pj_log_pop_indent()
342
349# define pj_log_set_color(level, color)
350
356# define pj_log_get_level() 0
357
363# define pj_log_get_decor() 0
364
371# define pj_log_get_color(level) 0
372
373
377# define pj_log_init() PJ_SUCCESS
378
379#endif /* #if PJ_LOG_MAX_LEVEL >= 1 */
380
385/* **************************************************************************/
386/*
387 * Log functions implementation prototypes.
388 * These functions are called by PJ_LOG macros according to verbosity
389 * level specified when calling the macro. Applications should not normally
390 * need to call these functions directly.
391 */
392
399#if PJ_LOG_MAX_LEVEL >= 1
400 #define pj_log_wrapper_1(arg) pj_log_1 arg
402 PJ_DECL(void) pj_log_1(const char *src, const char *format, ...);
403#else
404 #define pj_log_wrapper_1(arg)
405#endif
406
413#if PJ_LOG_MAX_LEVEL >= 2
414 #define pj_log_wrapper_2(arg) pj_log_2 arg
416 PJ_DECL(void) pj_log_2(const char *src, const char *format, ...);
417#else
418 #define pj_log_wrapper_2(arg)
419#endif
420
427#if PJ_LOG_MAX_LEVEL >= 3
428 #define pj_log_wrapper_3(arg) pj_log_3 arg
430 PJ_DECL(void) pj_log_3(const char *src, const char *format, ...);
431#else
432 #define pj_log_wrapper_3(arg)
433#endif
434
441#if PJ_LOG_MAX_LEVEL >= 4
442 #define pj_log_wrapper_4(arg) pj_log_4 arg
444 PJ_DECL(void) pj_log_4(const char *src, const char *format, ...);
445#else
446 #define pj_log_wrapper_4(arg)
447#endif
448
455#if PJ_LOG_MAX_LEVEL >= 5
456 #define pj_log_wrapper_5(arg) pj_log_5 arg
458 PJ_DECL(void) pj_log_5(const char *src, const char *format, ...);
459#else
460 #define pj_log_wrapper_5(arg)
461#endif
462
469#if PJ_LOG_MAX_LEVEL >= 6
470 #define pj_log_wrapper_6(arg) pj_log_6 arg
472 PJ_DECL(void) pj_log_6(const char *src, const char *format, ...);
473#else
474 #define pj_log_wrapper_6(arg)
475#endif
476
477
479
480#endif /* __PJ_LOG_H__ */
481
int pj_status_t
Definition: types.h:68
unsigned int pj_color_t
Definition: types.h:273
void pj_log_write(int level, const char *buffer, int len)
void pj_log_set_color(int level, pj_color_t color)
void pj_log_func(int level, const char *data, int len)
Definition: log.h:120
void pj_log_add_indent(int indent)
void pj_log(const char *sender, int level, const char *format, va_list marker)
pj_color_t pj_log_get_color(int level)
int pj_log_get_level(void)
pj_log_func * pj_log_get_log_func(void)
int pj_log_get_indent(void)
void pj_log_set_level(int level)
unsigned pj_log_get_decor(void)
pj_status_t pj_log_init(void)
void pj_log_push_indent(void)
void pj_log_pop_indent(void)
void pj_log_set_log_func(pj_log_func *func)
void pj_log_set_indent(int indent)
pj_log_decoration
Definition: log.h:70
void pj_log_set_decor(unsigned decor)
@ PJ_LOG_HAS_INDENT
Definition: log.h:85
@ PJ_LOG_HAS_DAY_OF_MON
Definition: log.h:74
@ PJ_LOG_HAS_TIME
Definition: log.h:75
@ PJ_LOG_HAS_NEWLINE
Definition: log.h:78
@ PJ_LOG_HAS_YEAR
Definition: log.h:72
@ PJ_LOG_HAS_SENDER
Definition: log.h:77
@ PJ_LOG_HAS_COLOR
Definition: log.h:81
@ PJ_LOG_HAS_LEVEL_TEXT
Definition: log.h:82
@ PJ_LOG_HAS_THREAD_SWC
Definition: log.h:84
@ PJ_LOG_HAS_MONTH
Definition: log.h:73
@ PJ_LOG_HAS_CR
Definition: log.h:79
@ PJ_LOG_HAS_MICRO_SEC
Definition: log.h:76
@ PJ_LOG_HAS_DAY_NAME
Definition: log.h:71
@ PJ_LOG_HAS_THREAD_ID
Definition: log.h:83
@ PJ_LOG_HAS_SPACE
Definition: log.h:80
#define PJ_BEGIN_DECL
Definition: config.h:1284
#define PJ_END_DECL
Definition: config.h:1285
void pj_log_1(const char *src, const char *format,...)
void pj_log_4(const char *src, const char *format,...)
void pj_log_2(const char *src, const char *format,...)
void pj_log_3(const char *src, const char *format,...)
Declaration of basic types and utility.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.