[asterisk-commits] tilghman: branch 1.8 r291038 - in /branches/1.8: cdr/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Oct 9 18:25:39 CDT 2010


Author: tilghman
Date: Sat Oct  9 18:25:37 2010
New Revision: 291038

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=291038
Log:
Add missing option to set calls to be logged in GMT/UTC.

Modified:
    branches/1.8/cdr/cdr_pgsql.c
    branches/1.8/configs/cdr_pgsql.conf.sample

Modified: branches/1.8/cdr/cdr_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/cdr/cdr_pgsql.c?view=diff&rev=291038&r1=291037&r2=291038
==============================================================================
--- branches/1.8/cdr/cdr_pgsql.c (original)
+++ branches/1.8/cdr/cdr_pgsql.c Sat Oct  9 18:25:37 2010
@@ -52,7 +52,7 @@
 
 static const char name[] = "pgsql";
 static const char config[] = "cdr_pgsql.conf";
-static char *pghostname = NULL, *pgdbname = NULL, *pgdbuser = NULL, *pgpassword = NULL, *pgdbport = NULL, *table = NULL, *encoding = NULL;
+static char *pghostname = NULL, *pgdbname = NULL, *pgdbuser = NULL, *pgpassword = NULL, *pgdbport = NULL, *table = NULL, *encoding = NULL, *tz = NULL;
 static int connected = 0;
 static int maxsize = 512, maxsize2 = 512;
 
@@ -177,7 +177,7 @@
 				} else {
 					/* char, hopefully */
 					LENGTHEN_BUF2(31);
-					ast_localtime(&cdr->start, &tm, NULL);
+					ast_localtime(&cdr->start, &tm, tz);
 					ast_strftime(buf, sizeof(buf), DATE_FORMAT, &tm);
 					ast_str_append(&sql2, 0, "%s%s", first ? "" : ",", buf);
 				}
@@ -191,7 +191,7 @@
 				} else {
 					/* char, hopefully */
 					LENGTHEN_BUF2(31);
-					ast_localtime(&cdr->start, &tm, NULL);
+					ast_localtime(&cdr->start, &tm, tz);
 					ast_strftime(buf, sizeof(buf), DATE_FORMAT, &tm);
 					ast_str_append(&sql2, 0, "%s%s", first ? "" : ",", buf);
 				}
@@ -205,7 +205,7 @@
 				} else {
 					/* char, hopefully */
 					LENGTHEN_BUF2(31);
-					ast_localtime(&cdr->end, &tm, NULL);
+					ast_localtime(&cdr->end, &tm, tz);
 					ast_strftime(buf, sizeof(buf), DATE_FORMAT, &tm);
 					ast_str_append(&sql2, 0, "%s%s", first ? "" : ",", buf);
 				}
@@ -341,18 +341,30 @@
 
 	PQfinish(conn);
 
-	if (pghostname)
+	if (pghostname) {
 		ast_free(pghostname);
-	if (pgdbname)
+	}
+	if (pgdbname) {
 		ast_free(pgdbname);
-	if (pgdbuser)
+	}
+	if (pgdbuser) {
 		ast_free(pgdbuser);
-	if (pgpassword)
+	}
+	if (pgpassword) {
 		ast_free(pgpassword);
-	if (pgdbport)
+	}
+	if (pgdbport) {
 		ast_free(pgdbport);
-	if (table)
+	}
+	if (table) {
 		ast_free(table);
+	}
+	if (encoding) {
+		ast_free(encoding);
+	}
+	if (tz) {
+		ast_free(tz);
+	}
 
 	AST_RWLIST_WRLOCK(&psql_columns);
 	while ((current = AST_RWLIST_REMOVE_HEAD(&psql_columns, list))) {
@@ -469,6 +481,19 @@
 		return -1;
 	}
 
+	if (!(tmp = ast_variable_retrieve(cfg, "global", "timezone"))) {
+		tmp = "";
+	}
+
+	if (tz) {
+		ast_free(tz);
+		tz = NULL;
+	}
+	if (!ast_strlen_zero(tmp) && !(tz = ast_strdup(tmp))) {
+		ast_config_destroy(cfg);
+		return -1;
+	}
+
 	if (option_debug) {
 		if (ast_strlen_zero(pghostname)) {
 			ast_debug(1, "using default unix socket\n");
@@ -480,6 +505,8 @@
 		ast_debug(1, "got dbname of %s\n", pgdbname);
 		ast_debug(1, "got password of %s\n", pgpassword);
 		ast_debug(1, "got sql table name of %s\n", table);
+		ast_debug(1, "got encoding of %s\n", encoding);
+		ast_debug(1, "got timezone of %s\n", tz);
 	}
 
 	conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);

Modified: branches/1.8/configs/cdr_pgsql.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/configs/cdr_pgsql.conf.sample?view=diff&rev=291038&r1=291037&r2=291038
==============================================================================
--- branches/1.8/configs/cdr_pgsql.conf.sample (original)
+++ branches/1.8/configs/cdr_pgsql.conf.sample Sat Oct  9 18:25:37 2010
@@ -12,3 +12,4 @@
 ;user=postgres
 ;table=cdr		;SQL table where CDRs will be inserted
 ;encoding=LATIN9	; Encoding of logged characters in Asterisk
+;timezone=UTC		; Uncomment if you want datetime fields in UTC/GMT




More information about the asterisk-commits mailing list