Skip to content
Snippets Groups Projects
Commit 275f0ed0 authored by Jeremy McNamara's avatar Jeremy McNamara
Browse files

Add userfield logging

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1948 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent da6648f3
No related branches found
No related tags found
No related merge requests found
......@@ -76,7 +76,7 @@ static int pgsql_log(struct ast_cdr *cdr)
if (connected) {
char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL;
char *uniqueid=NULL;
char *uniqueid=NULL, *userfield=NULL;
/* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
if ((clid = alloca(strlen(cdr->clid) * 2 + 1)) != NULL)
......@@ -93,9 +93,11 @@ static int pgsql_log(struct ast_cdr *cdr)
PQescapeString(lastdata, cdr->lastdata, strlen(cdr->lastdata));
if ((uniqueid = alloca(strlen(cdr->uniqueid) * 2 + 1)) != NULL)
PQescapeString(uniqueid, cdr->uniqueid, strlen(cdr->uniqueid));
if ((userfield = alloca(strlen(cdr->userfield) * 2 + 1)) !+ NULL)
PQescapeString(userfield, cdr->userfield, strlen(cdr->userfield));
/* Check for all alloca failures above at once */
if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata) || (!uniqueid)) {
if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata) || (!uniqueid) || (!userfield)) {
ast_log(LOG_ERROR, "cdr_pgsql: Out of memory error (insert fails)\n");
ast_mutex_unlock(&pgsql_lock);
return -1;
......@@ -103,7 +105,7 @@ static int pgsql_log(struct ast_cdr *cdr)
ast_log(LOG_DEBUG,"cdr_pgsql: inserting a CDR record.\n");
sprintf(sqlcmd,"INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s')",timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid);
sprintf(sqlcmd,"INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s','%s')",timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid, userfield);
ast_log(LOG_DEBUG,"cdr_pgsql: SQL command executed: %s\n",sqlcmd);
/* Test to be sure we're still connected... */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment