[sr-dev] git:master:d20cc8be: core: added framework to allow replacing logging to syslog

Daniel-Constantin Mierla miconda at gmail.com
Wed Oct 21 09:52:13 CEST 2015


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-10-21T09:51:54+02:00

core: added framework to allow replacing logging to syslog

- this enables a module to replace all logging to syslog with another
logging mechanism
- it is not enabled when log_stderror=yes or the system is detected as
__SUNPRO_C

---

Modified: dprint.c
Modified: dprint.h

---

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

---

diff --git a/dprint.c b/dprint.c
index ebb5059..a2a2961 100644
--- a/dprint.c
+++ b/dprint.c
@@ -36,6 +36,19 @@
 #include <stdio.h>
 #include <strings.h>
 
+char *_km_log_engine_type = NULL;
+char *_km_log_engine_data = NULL;
+
+km_log_f _km_log_func = &syslog;
+
+/**
+ *
+ */
+void km_log_func_set(km_log_f f)
+{
+	_km_log_func = f;
+}
+
 #ifndef NO_SIG_DEBUG
 /* signal protection: !=0 when LOG/DBG/... are printing */
 volatile int dprint_crit = 0; 
diff --git a/dprint.h b/dprint.h
index 40fc62a..35d5a0d 100644
--- a/dprint.h
+++ b/dprint.h
@@ -123,6 +123,13 @@ extern int log_stderr;
 extern int log_color;
 extern char *log_prefix_fmt;
 extern str *log_prefix_val;
+extern char *_km_log_engine_type;
+extern char *_km_log_engine_data;
+
+typedef void (*km_log_f)(int, const char *, ...);
+extern km_log_f _km_log_func;
+
+void km_log_func_set(km_log_f f);
 
 /** @brief maps log levels to their string name and corresponding syslog level */
 
@@ -303,7 +310,7 @@ void log_prefix_init(void);
 						if (unlikely(log_color)) dprint_color_reset(); \
 					} else { \
 						if(unlikely(log_prefix_val)) { \
-							syslog(LOG2SYSLOG_LEVEL(__llevel) |\
+							_km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\
 							   (((facility) != DEFAULT_FACILITY) ? \
 								(facility) : \
 								get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \
@@ -312,7 +319,7 @@ void log_prefix_init(void);
 								(lname)?(lname):LOG_LEVEL2NAME(__llevel),\
 								(prefix) , ## args); \
 						} else { \
-							syslog(LOG2SYSLOG_LEVEL(__llevel) |\
+							_km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\
 							   (((facility) != DEFAULT_FACILITY) ? \
 								(facility) : \
 								get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \




More information about the sr-dev mailing list