Module: kamailio
Branch: master
Commit: c5c84099fc29623c4f0b8faf9e6151eeaf4421c1
URL: 
https://github.com/kamailio/kamailio/commit/c5c84099fc29623c4f0b8faf9e6151eeaf4421c1

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2024-09-09T11:29:20+02:00

core: dprint - add possibility to set the structured log function

---

Modified: src/core/dprint.c
Modified: src/core/dprint.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/c5c84099fc29623c4f0b8faf9e6151eeaf4421c1.diff
Patch: 
https://github.com/kamailio/kamailio/commit/c5c84099fc29623c4f0b8faf9e6151eeaf4421c1.patch

---

diff --git a/src/core/dprint.c b/src/core/dprint.c
index 83d1e30f3ca..f167fac0fc4 100644
--- a/src/core/dprint.c
+++ b/src/core/dprint.c
@@ -828,6 +828,14 @@ void ksr_slog_init(char *ename)
        }
 }
 
+/**
+ *
+ */
+void km_slog_func_set(ksr_slog_f f)
+{
+       _ksr_slog_func = f;
+}
+
 static void log_callid_set(sip_msg_t *msg)
 {
        if(!(_ksr_slog_json_flags & KSR_SLOGJSON_FL_CALLID)) {
diff --git a/src/core/dprint.h b/src/core/dprint.h
index 13957b269c9..a72b297e194 100644
--- a/src/core/dprint.h
+++ b/src/core/dprint.h
@@ -112,7 +112,8 @@
 /**
  *
  */
-typedef struct ksr_loglevels {
+typedef struct ksr_loglevels
+{
        int ll_alert;
        int ll_bug;
        int ll_crit;
@@ -123,8 +124,10 @@ typedef struct ksr_loglevels {
        int ll_dbg;
 } ksr_loglevels_t;
 
-#define KSR_LOGLEVELS_DEFAULTS {L_ALERT, L_BUG, L_CRIT2, L_ERR, L_WARN, \
-       L_NOTICE, L_INFO, L_DBG}
+#define KSR_LOGLEVELS_DEFAULTS                                          \
+       {                                                                   \
+               L_ALERT, L_BUG, L_CRIT2, L_ERR, L_WARN, L_NOTICE, L_INFO, L_DBG 
\
+       }
 /**
  * data fileds used for structured logging
  */
@@ -148,6 +151,7 @@ typedef void (*ksr_slog_f)(ksr_logdata_t *, const char *, 
...);
 void ksr_slog_init(char *ename);
 
 extern ksr_slog_f _ksr_slog_func;
+void km_slog_func_set(ksr_slog_f f);
 
 /** @brief my_pid(), process_no are from pt.h but we cannot \#include it here
    because of circular dependencies */
@@ -458,9 +462,9 @@ void log_prefix_init(void);
 
 #ifdef MOD_NAMEID
 
-#define KSR_LLMODVAR_COMBINEZ(X,Y) X##Y
-#define KSR_LLMODVAR_COMBINE(X,Y) KSR_LLMODVAR_COMBINEZ(X,Y)
-#define KSR_LLMODVAR KSR_LLMODVAR_COMBINE(_ksr_loglevels_,MOD_NAMEID)
+#define KSR_LLMODVAR_COMBINEZ(X, Y) X##Y
+#define KSR_LLMODVAR_COMBINE(X, Y) KSR_LLMODVAR_COMBINEZ(X, Y)
+#define KSR_LLMODVAR KSR_LLMODVAR_COMBINE(_ksr_loglevels_, MOD_NAMEID)
 
 /* use local log level mapping */
 #define LLM_ALERT(fmt, args...) LOG(KSR_LLMODVAR.alert, fmt, ##args)

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to