Module: kamailio Branch: master Commit: b36f7c9aed3f5cebc457b26f40ca472665da4d00 URL: https://github.com/kamailio/kamailio/commit/b36f7c9aed3f5cebc457b26f40ca4726...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2016-04-07T09:39:44+02:00
core: new global parameter log_prefix_mode
- if set to 0 (default), then log_prefix is evaluated when the sip message is received and then reused (recommended if the log_prefix has only variables that have same value for same message). This is the current behaviour of log_prefix evaluation. - if set to 1, then the log prefix is evaluated before/after each config action (needs to be set when the log_prefix has variables that are different based on the context of config execution, e.g., $cfg(line))
---
Modified: action.c Modified: cfg.lex Modified: cfg.y Modified: dprint.c Modified: dprint.h
---
Diff: https://github.com/kamailio/kamailio/commit/b36f7c9aed3f5cebc457b26f40ca4726... Patch: https://github.com/kamailio/kamailio/commit/b36f7c9aed3f5cebc457b26f40ca4726...
---
diff --git a/action.c b/action.c index bef3ec6..9e9db97 100644 --- a/action.c +++ b/action.c @@ -1546,8 +1546,14 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg) if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) ms = TICKS_TO_MS(get_ticks_raw()); _cfg_crt_action = t; + if(unlikely(log_prefix_mode==1)) { + log_prefix_set(msg); + } ret=do_action(h, t, msg); _cfg_crt_action = 0; + if(unlikely(log_prefix_mode==1)) { + log_prefix_set(msg); + } if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) { ms = TICKS_TO_MS(get_ticks_raw()) - ms; if(ms >= cfg_get(core, core_cfg, latency_limit_action)) { diff --git a/cfg.lex b/cfg.lex index 5aeadf0..1544e6e 100644 --- a/cfg.lex +++ b/cfg.lex @@ -290,6 +290,7 @@ LOGFACILITY log_facility LOGNAME log_name LOGCOLOR log_color LOGPREFIX log_prefix +LOGPREFIXMODE log_prefix_mode LOGENGINETYPE log_engine_type LOGENGINEDATA log_engine_data LISTEN listen @@ -673,6 +674,7 @@ IMPORTFILE "import_file" <INITIAL>{LOGNAME} { yylval.strval=yytext; return LOGNAME; } <INITIAL>{LOGCOLOR} { yylval.strval=yytext; return LOGCOLOR; } <INITIAL>{LOGPREFIX} { yylval.strval=yytext; return LOGPREFIX; } +<INITIAL>{LOGPREFIXMODE} { yylval.strval=yytext; return LOGPREFIXMODE; } <INITIAL>{LOGENGINETYPE} { yylval.strval=yytext; return LOGENGINETYPE; } <INITIAL>{LOGENGINEDATA} { yylval.strval=yytext; return LOGENGINEDATA; } <INITIAL>{LISTEN} { count(); yylval.strval=yytext; return LISTEN; } diff --git a/cfg.y b/cfg.y index aa9b0ca..24b2240 100644 --- a/cfg.y +++ b/cfg.y @@ -320,6 +320,7 @@ extern char *default_routename; %token LOGNAME %token LOGCOLOR %token LOGPREFIX +%token LOGPREFIXMODE %token LOGENGINETYPE %token LOGENGINEDATA %token LISTEN @@ -777,6 +778,8 @@ assign_stm: | LOGCOLOR EQUAL error { yyerror("boolean value expected"); } | LOGPREFIX EQUAL STRING { log_prefix_fmt=$3; } | LOGPREFIX EQUAL error { yyerror("string value expected"); } + | LOGPREFIXMODE EQUAL NUMBER { log_prefix_mode=$3; } + | LOGPREFIXMODE EQUAL error { yyerror("number expected"); } | LOGENGINETYPE EQUAL STRING { _km_log_engine_type=$3; } | LOGENGINETYPE EQUAL error { yyerror("string value expected"); } | LOGENGINEDATA EQUAL STRING { _km_log_engine_data=$3; } diff --git a/dprint.c b/dprint.c index 269dd83..46d69a1 100644 --- a/dprint.c +++ b/dprint.c @@ -432,6 +432,7 @@ void dprint_color_update(int level, char f, char b)
/* log_prefix functionality */ str *log_prefix_val = NULL; +int log_prefix_mode = 0; static pv_elem_t *log_prefix_pvs = NULL;
#define LOG_PREFIX_SIZE 1024 diff --git a/dprint.h b/dprint.h index 5f03445..69d2622 100644 --- a/dprint.h +++ b/dprint.h @@ -123,6 +123,7 @@ extern int log_stderr; extern int log_color; extern char *log_prefix_fmt; extern str *log_prefix_val; +extern int log_prefix_mode; extern char *_km_log_engine_type; extern char *_km_log_engine_data;