PJSIP UA分析(1)——log管理

1 log配置结构

 

1 /**
2 * Logging configuration, which can be (optionally) specified when calling
3 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
4 * initialize this structure with the default values.
5 */
6 typedef struct pjsua_logging_config
7 {
8 /**
9 * Log incoming and outgoing SIP message? Yes!
10 */
11 pj_bool_t msg_logging;
12
13 /**
14 * Input verbosity level. Value 5 is reasonable.
15 */
16 unsigned level;
17
18 /**
19 * Verbosity level for console. Value 4 is reasonable.
20 */
21 unsigned console_level;
22
23 /**
24 * Log decoration.
25 */
26 unsigned decor;
27
28 /**
29 * Optional log filename.
30 */
31 pj_str_t log_filename;
32
33 /**
34 * Additional flags to be given to #pj_file_open() when opening
35 * the log file. By default, the flag is PJ_O_WRONLY. Application
36 * may set PJ_O_APPEND here so that logs are appended to existing
37 * file instead of overwriting it.
38 *
39 * Default is 0.
40 */
41 unsigned log_file_flags;
42
43 /**
44 * Optional callback function to be called to write log to
45 * application specific device. This function will be called for
46 * log messages on input verbosity level.
47 */
48 void (*cb)(int level, const char *data, int len);
49
50
51 } pjsua_logging_config;

2 默认配置函数

 

1 PJ_DEF(void) pjsua_logging_config_default(pjsua_logging_config *cfg)
2 {
3 pj_bzero(cfg, sizeof(*cfg));
4
5 cfg->msg_logging = PJ_TRUE;
6 cfg->level = 5;
7 cfg->console_level = 4;
8 cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME |
9 PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE |
10 PJ_LOG_HAS_SPACE;
11  #if defined(PJ_WIN32) && PJ_WIN32 != 0
12 cfg->decor |= PJ_LOG_HAS_COLOR;
13  #endif
14 }

 

posted @ 2010-11-09 23:12  茫茫深海一条鱼  阅读(2081)  评论(0编辑  收藏  举报