Browse Source

xlog: evaluate prefix for kemi functions

Daniel-Constantin Mierla 9 months ago
parent
commit
76e18d0d13
1 changed files with 14 additions and 2 deletions
  1. 14 2
      src/modules/xlog/xlog.c

+ 14 - 2
src/modules/xlog/xlog.c

@@ -886,6 +886,7 @@ int ki_xlog_ex(sip_msg_t *msg, str *lfacility, int llevel, str *lmsg)
 	int lf = xlog_facility;
 	pv_elem_t *xmodel = NULL;
 	str txt = {0, 0};
+	char *_xlog_prefix_val = _xlog_prefix;
 
 	if(!is_printable(llevel))
 		return 1;
@@ -901,6 +902,18 @@ int ki_xlog_ex(sip_msg_t *msg, str *lfacility, int llevel, str *lmsg)
 		return -1;
 	}
 
+	if(_xlog_prefix_mode) {
+		str _xlog_prefix_str;
+		_xlog_prefix_str.s = _xlog_prefix_buf;
+		_xlog_prefix_str.len = buf_size;
+		if(pv_printf(msg, _xlog_prefix_pvs, _xlog_prefix_str.s,
+				   &_xlog_prefix_str.len)
+						== 0
+				&& _xlog_prefix_str.len > 0) {
+			_xlog_prefix_val = _xlog_prefix_buf;
+		}
+	}
+
 	if(lfacility != NULL) {
 		lfacility->s[lfacility->len] = '\0';
 		lf = str2facility(lfacility->s);
@@ -910,8 +923,7 @@ int ki_xlog_ex(sip_msg_t *msg, str *lfacility, int llevel, str *lmsg)
 			lf = xlog_facility;
 		}
 	}
-	LOG_FN(lf, llevel, _xlog_prefix, "%.*s", txt.len, txt.s);
-	;
+	LOG_FN(lf, llevel, _xlog_prefix_val, "%.*s", txt.len, txt.s);
 	pv_elem_free_all(xmodel);
 	return 1;
 }