diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-12-26 15:58:17 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-12-26 15:58:17 +0000 |
commit | 06049447cd0c1b41027a2d95174ad458e09c4750 (patch) | |
tree | 961920f156eaf5a0fc1ef1f9eb4674e97020fdf9 /main/logger.c | |
parent | 7f64f70d63ce1451e8984561417ca232e2235ea6 (diff) |
Adding support for storing the queue log entries in a realtime backend.
(closes issue #11625, reported and patched by sergee)
Thank you very much to sergee for adding this new feature!
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@94782 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/logger.c')
-rw-r--r-- | main/logger.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/main/logger.c b/main/logger.c index c82862e6b..252b620b6 100644 --- a/main/logger.c +++ b/main/logger.c @@ -418,18 +418,34 @@ void ast_queue_log(const char *queuename, const char *callid, const char *agent, va_list ap; char qlog_msg[8192]; int qlog_len; - if (qlog) { + char time_str[16]; + + if (ast_check_realtime("queue_log")) { va_start(ap, fmt); - qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event); - vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap); + vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap); va_end(ap); + snprintf(time_str, sizeof(time_str), "%ld", (long)time(NULL)); + ast_store_realtime("queue_log", "time", time_str, + "callid", callid, + "queuename", queuename, + "agent", agent, + "event", event, + "data", qlog_msg, + NULL); + } else { + if (qlog) { + va_start(ap, fmt); + qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event); + vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap); + va_end(ap); + } + AST_RWLIST_RDLOCK(&logchannels); + if (qlog) { + fprintf(qlog, "%s\n", qlog_msg); + fflush(qlog); + } + AST_RWLIST_UNLOCK(&logchannels); } - AST_RWLIST_RDLOCK(&logchannels); - if (qlog) { - fprintf(qlog, "%s\n", qlog_msg); - fflush(qlog); - } - AST_RWLIST_UNLOCK(&logchannels); } static int rotate_file(const char *filename) |