summaryrefslogtreecommitdiff
path: root/main/logger.c
diff options
context:
space:
mode:
authorMichael L. Young <elgueromexicano@gmail.com>2013-05-13 21:21:03 +0000
committerMichael L. Young <elgueromexicano@gmail.com>2013-05-13 21:21:03 +0000
commit54424c2ee2370d3d9dcb61ad438bc5d5ee2cbcdd (patch)
tree29c3500cc09079e356f782f24c7137c4e04637d0 /main/logger.c
parent4ff6e61808c56b68ad2e48d5a0bb50ecbfe94a92 (diff)
Fix Missing CALL-ID When Logging Through Syslog
The CALL-ID (ie [C-00000074]) is missing when logging to syslog. This was just an oversight when this feature was added. * Add CALL-IDs when using syslog (closes issue ASTERISK-21430) Reported by: Nikola Ciprich Tested by: Nikola Ciprich, Michael L. Young Patches: asterisk-21430-syslog-callid_trunk.diff by Michael L. Young (license 5026) Review: https://reviewboard.asterisk.org/r/2526/ ........ Merged revisions 388605 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388617 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/logger.c')
-rw-r--r--main/logger.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/main/logger.c b/main/logger.c
index 72499dd0e..0ee3ae0e2 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -1016,6 +1016,13 @@ static void ast_log_vsyslog(struct logmsg *msg)
{
char buf[BUFSIZ];
int syslog_level = ast_syslog_priority_from_loglevel(msg->level);
+ char call_identifier_str[13];
+
+ if (msg->callid) {
+ snprintf(call_identifier_str, sizeof(call_identifier_str), "[C-%08x]", msg->callid->call_identifier);
+ } else {
+ call_identifier_str[0] = '\0';
+ }
if (syslog_level < 0) {
/* we are locked here, so cannot ast_log() */
@@ -1023,8 +1030,8 @@ static void ast_log_vsyslog(struct logmsg *msg)
return;
}
- snprintf(buf, sizeof(buf), "%s[%d]: %s:%d in %s: %s",
- levels[msg->level], msg->lwp, msg->file, msg->line, msg->function, msg->message);
+ snprintf(buf, sizeof(buf), "%s[%d]%s: %s:%d in %s: %s",
+ levels[msg->level], msg->lwp, call_identifier_str, msg->file, msg->line, msg->function, msg->message);
term_strip(buf, buf, strlen(buf) + 1);
syslog(syslog_level, "%s", buf);