Module: kamailio Branch: master Commit: 786d75cce04f5e2366769d4ed56d9da3924daf97 URL: https://github.com/kamailio/kamailio/commit/786d75cce04f5e2366769d4ed56d9da3924daf97
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2025-11-05T11:59:28+01:00 core: log_prefix_mode value 2 to use faked request for non-sip logging --- Modified: src/core/dprint.c Modified: src/core/dprint.h Modified: src/main.c --- Diff: https://github.com/kamailio/kamailio/commit/786d75cce04f5e2366769d4ed56d9da3924daf97.diff Patch: https://github.com/kamailio/kamailio/commit/786d75cce04f5e2366769d4ed56d9da3924daf97.patch --- diff --git a/src/core/dprint.c b/src/core/dprint.c index 9f00621de68..661ddd55539 100644 --- a/src/core/dprint.c +++ b/src/core/dprint.c @@ -42,6 +42,7 @@ #include "globals.h" #include "dprint.h" #include "pvar.h" +#include "fmsg.h" #include "strutils.h" static void log_callid_set(sip_msg_t *msg); @@ -50,6 +51,7 @@ char *_km_log_engine_type = NULL; char *_km_log_engine_data = NULL; km_log_f _km_log_func = &syslog; +static sip_msg_t _km_log_prefix_fmsg = {0}; /** * @@ -504,18 +506,40 @@ void log_prefix_init(void) } } +sip_msg_t *km_log_prefix_msg_get(sip_msg_t *msg) +{ + if(msg != NULL) { + return msg; + } + if(!(log_prefix_mode & LOG_PREFIX_MODE_FMSG)) { + return NULL; + } + if(_km_log_prefix_fmsg.len == 0) { + if(faked_msg_get_new(&_km_log_prefix_fmsg) < 0) { + return NULL; + } + if(parse_headers(&_km_log_prefix_fmsg, HDR_EOH_F, 0) < 0) { + return NULL; + } + } + return &_km_log_prefix_fmsg; +} + void log_prefix_set(sip_msg_t *msg) { - log_callid_set(msg); + sip_msg_t *lmsg = NULL; + + lmsg = km_log_prefix_msg_get(msg); + log_callid_set(lmsg); if(log_prefix_pvs == NULL) return; - if(msg == NULL || !IS_SIP_MSG(msg)) { + if(lmsg == NULL || !IS_SIP_MSG(lmsg)) { log_prefix_val = NULL; return; } log_prefix_str.s = log_prefix_buf; log_prefix_str.len = LOG_PREFIX_SIZE; - if(pv_printf(msg, log_prefix_pvs, log_prefix_str.s, &log_prefix_str.len) + if(pv_printf(lmsg, log_prefix_pvs, log_prefix_str.s, &log_prefix_str.len) < 0) return; if(log_prefix_str.len <= 0) diff --git a/src/core/dprint.h b/src/core/dprint.h index 379fde55196..919613a05ea 100644 --- a/src/core/dprint.h +++ b/src/core/dprint.h @@ -162,6 +162,7 @@ extern int my_pid(void); extern int log_stderr; #define LOG_PREFIX_MODE_REFRESH 1 +#define LOG_PREFIX_MODE_FMSG 2 extern int log_color; extern int log_cee; diff --git a/src/main.c b/src/main.c index f36e73ac784..e0f3720e520 100644 --- a/src/main.c +++ b/src/main.c @@ -1490,6 +1490,7 @@ int main_loop(void) /* init log prefix format */ log_prefix_init(); + log_prefix_set(NULL); /* init childs with rank==PROC_INIT before forking any process, * this is a place for delayed (after mod_init) initializations @@ -1766,6 +1767,7 @@ int main_loop(void) /* init log prefix format */ log_prefix_init(); + log_prefix_set(NULL); /* init childs with rank==PROC_INIT before forking any process, * this is a place for delayed (after mod_init) initializations @@ -3072,8 +3074,9 @@ int main(int argc, char **argv) dont_fork = dont_fork == 1; } /* init locks first */ - if(init_lock_ops() != 0) + if(init_lock_ops() != 0) { goto error; + } #ifdef USE_TCP #ifdef USE_TLS if(tcp_disable) _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
