mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 00:24:05 +00:00
Optionally store CDR's in GM time (bug #3500, with mods)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4962 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -39,6 +39,7 @@ static char *config = "cdr_odbc.conf";
|
|||||||
static char *dsn = NULL, *username = NULL, *password = NULL, *table = NULL;
|
static char *dsn = NULL, *username = NULL, *password = NULL, *table = NULL;
|
||||||
static int dsn_alloc = 0, username_alloc = 0, password_alloc = 0, table_alloc = 0;
|
static int dsn_alloc = 0, username_alloc = 0, password_alloc = 0, table_alloc = 0;
|
||||||
static int loguniqueid = 0;
|
static int loguniqueid = 0;
|
||||||
|
static int usegmtime = 0;
|
||||||
static int dispositionstring = 0;
|
static int dispositionstring = 0;
|
||||||
static int connected = 0;
|
static int connected = 0;
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ static SQLHSTMT ODBC_stmt; /* global ODBC Statement Handle */
|
|||||||
|
|
||||||
static int odbc_log(struct ast_cdr *cdr)
|
static int odbc_log(struct ast_cdr *cdr)
|
||||||
{
|
{
|
||||||
long int ODBC_err;
|
SQLINTEGER ODBC_err;
|
||||||
short int ODBC_mlen;
|
short int ODBC_mlen;
|
||||||
int ODBC_res;
|
int ODBC_res;
|
||||||
char ODBC_msg[200], ODBC_stat[10];
|
char ODBC_msg[200], ODBC_stat[10];
|
||||||
@@ -61,7 +62,10 @@ static int odbc_log(struct ast_cdr *cdr)
|
|||||||
int res = 0;
|
int res = 0;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
localtime_r(&cdr->start.tv_sec,&tm);
|
if (usegmtime)
|
||||||
|
gmtime_r(&cdr->start.tv_sec,&tm);
|
||||||
|
else
|
||||||
|
localtime_r(&cdr->start.tv_sec,&tm);
|
||||||
|
|
||||||
ast_mutex_lock(&odbc_lock);
|
ast_mutex_lock(&odbc_lock);
|
||||||
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
|
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
|
||||||
@@ -215,6 +219,7 @@ static int odbc_unload_module(void)
|
|||||||
table_alloc = 0;
|
table_alloc = 0;
|
||||||
}
|
}
|
||||||
loguniqueid = 0;
|
loguniqueid = 0;
|
||||||
|
usegmtime = 0;
|
||||||
dispositionstring = 0;
|
dispositionstring = 0;
|
||||||
|
|
||||||
ast_cdr_unregister(name);
|
ast_cdr_unregister(name);
|
||||||
@@ -305,15 +310,28 @@ static int odbc_load_module(void)
|
|||||||
if (tmp) {
|
if (tmp) {
|
||||||
loguniqueid = ast_true(tmp);
|
loguniqueid = ast_true(tmp);
|
||||||
if (loguniqueid) {
|
if (loguniqueid) {
|
||||||
ast_log(LOG_NOTICE,"cdr_odbc: Logging uniqueid\n");
|
ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n");
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_ERROR,"cdr_odbc: Not logging uniqueid\n");
|
ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING,"cdr_odbc: Not logging uniqueid\n");
|
ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
|
||||||
loguniqueid = 0;
|
loguniqueid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmp = ast_variable_retrieve(cfg,"global","usegmtime");
|
||||||
|
if (tmp) {
|
||||||
|
usegmtime = ast_true(tmp);
|
||||||
|
if (usegmtime) {
|
||||||
|
ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n");
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
|
||||||
|
usegmtime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
tmp = ast_variable_retrieve(cfg,"global","table");
|
tmp = ast_variable_retrieve(cfg,"global","table");
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
table = malloc(strlen(tmp) + 1);
|
table = malloc(strlen(tmp) + 1);
|
||||||
@@ -357,7 +375,7 @@ out:
|
|||||||
|
|
||||||
static int odbc_do_query(void)
|
static int odbc_do_query(void)
|
||||||
{
|
{
|
||||||
long int ODBC_err;
|
SQLINTEGER ODBC_err;
|
||||||
int ODBC_res;
|
int ODBC_res;
|
||||||
short int ODBC_mlen;
|
short int ODBC_mlen;
|
||||||
char ODBC_msg[200], ODBC_stat[10];
|
char ODBC_msg[200], ODBC_stat[10];
|
||||||
@@ -381,7 +399,7 @@ static int odbc_do_query(void)
|
|||||||
|
|
||||||
static int odbc_init(void)
|
static int odbc_init(void)
|
||||||
{
|
{
|
||||||
long int ODBC_err;
|
SQLINTEGER ODBC_err;
|
||||||
short int ODBC_mlen;
|
short int ODBC_mlen;
|
||||||
int ODBC_res;
|
int ODBC_res;
|
||||||
char ODBC_msg[200], ODBC_stat[10];
|
char ODBC_msg[200], ODBC_stat[10];
|
||||||
|
@@ -9,3 +9,4 @@
|
|||||||
;loguniqueid=yes
|
;loguniqueid=yes
|
||||||
;dispositionstring=yes
|
;dispositionstring=yes
|
||||||
;table=cdr ;"cdr" is default table name
|
;table=cdr ;"cdr" is default table name
|
||||||
|
;usegmtime=no ; set to "yes" to log in GMT
|
||||||
|
Reference in New Issue
Block a user