Module: kamailio
Branch: 5.4
Commit: 1ecade5cbd323e1ab45ec6f83236e1d389739d3b
URL:
https://github.com/kamailio/kamailio/commit/1ecade5cbd323e1ab45ec6f83236e1d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-08-24T10:07:27+02:00
log_custom: print to stderror if sending log message fails
- help troubleshooting while avoiding looping to same function in case
the log engine is set to log custom module
(cherry picked from commit f16d046f6330f897b374d9bb7dab3b2ce8eab3a7)
---
Modified: src/modules/log_custom/log_custom_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1ecade5cbd323e1ab45ec6f83236e1d…
Patch:
https://github.com/kamailio/kamailio/commit/1ecade5cbd323e1ab45ec6f83236e1d…
---
diff --git a/src/modules/log_custom/log_custom_mod.c
b/src/modules/log_custom/log_custom_mod.c
index 5253dad37e..a0f2e7542e 100644
--- a/src/modules/log_custom/log_custom_mod.c
+++ b/src/modules/log_custom/log_custom_mod.c
@@ -139,6 +139,7 @@ void _lc_core_log_udp(int lpriority, const char *format, ...)
va_list arglist;
char obuf[LC_LOG_MSG_MAX_SIZE];
int n;
+ int r;
va_start(arglist, format);
@@ -146,8 +147,11 @@ void _lc_core_log_udp(int lpriority, const char *format, ...)
n += snprintf(obuf + n, LC_LOG_MSG_MAX_SIZE - n, "(%d) ", my_pid());
n += vsnprintf(obuf + n, LC_LOG_MSG_MAX_SIZE - n, format, arglist);
va_end(arglist);
- if(udp_send(&_lc_udp_dst, obuf, n)!=0) {
- udp_send(&_lc_udp_dst, "debug: previous udp send returned non zero\n",
43);
+ r = udp_send(&_lc_udp_dst, obuf, n);
+ if(r<0) {
+ /* sending log message failed - print to stderror to help debugging */
+ fprintf(stderr, "error: previous udp send returned failure (%d:%d:%s)\n",
+ r, errno, strerror(errno));
}
}
@@ -160,9 +164,9 @@ int ki_log_udp(sip_msg_t *msg, str *txt)
ret=udp_send(&_lc_udp_dst, txt->s, txt->len);
- if(ret==0) return 1;
+ if(ret>0) return 1;
- return ret;
+ return (ret==0)?-1:ret;
}