connected = 1;
} else {
pgerror = PQerrorMessage(conn);
- ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s. Calls will not be logged!\n", pghostname);
- ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
+ ast_log(LOG_ERROR, "Unable to connect to database server %s. Calls will not be logged!\n", pghostname);
+ ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
PQfinish(conn);
conn = NULL;
}
strcat(sql + lensql, sql2);
ast_verb(11, "[%s]\n", sql);
- ast_debug(2, "cdr_pgsql: inserting a CDR record.\n");
+ ast_debug(2, "inserting a CDR record.\n");
/* Test to be sure we're still connected... */
/* If we're connected, and connection is working, good. */
if (PQstatus(conn) == CONNECTION_OK) {
connected = 1;
} else {
- ast_log(LOG_ERROR, "cdr_pgsql: Connection was lost... attempting to reconnect.\n");
+ ast_log(LOG_ERROR, "Connection was lost... attempting to reconnect.\n");
PQreset(conn);
if (PQstatus(conn) == CONNECTION_OK) {
- ast_log(LOG_ERROR, "cdr_pgsql: Connection reestablished.\n");
+ ast_log(LOG_ERROR, "Connection reestablished.\n");
connected = 1;
} else {
pgerror = PQerrorMessage(conn);
- ast_log(LOG_ERROR, "cdr_pgsql: Unable to reconnect to database server %s. Calls will not be logged!\n", pghostname);
- ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
+ ast_log(LOG_ERROR, "Unable to reconnect to database server %s. Calls will not be logged!\n", pghostname);
+ ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
PQfinish(conn);
conn = NULL;
connected = 0;
result = PQexec(conn, sql);
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
pgerror = PQresultErrorMessage(result);
- ast_log(LOG_ERROR,"cdr_pgsql: Failed to insert call detail record into database!\n");
- ast_log(LOG_ERROR,"cdr_pgsql: Reason: %s\n", pgerror);
- ast_log(LOG_ERROR,"cdr_pgsql: Connection may have been lost... attempting to reconnect.\n");
+ ast_log(LOG_ERROR, "Failed to insert call detail record into database!\n");
+ ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
+ ast_log(LOG_ERROR, "Connection may have been lost... attempting to reconnect.\n");
PQreset(conn);
if (PQstatus(conn) == CONNECTION_OK) {
- ast_log(LOG_ERROR, "cdr_pgsql: Connection reestablished.\n");
+ ast_log(LOG_ERROR, "Connection reestablished.\n");
connected = 1;
PQclear(result);
result = PQexec(conn, sql);
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
pgerror = PQresultErrorMessage(result);
- ast_log(LOG_ERROR,"cdr_pgsql: HARD ERROR! Attempted reconnection failed. DROPPING CALL RECORD!\n");
- ast_log(LOG_ERROR,"cdr_pgsql: Reason: %s\n", pgerror);
+ ast_log(LOG_ERROR, "HARD ERROR! Attempted reconnection failed. DROPPING CALL RECORD!\n");
+ ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
}
}
ast_mutex_unlock(&pgsql_lock);
}
if (!(tmp = ast_variable_retrieve(cfg, "global", "dbname"))) {
- ast_log(LOG_WARNING,"PostgreSQL database not specified. Assuming asterisk\n");
+ ast_log(LOG_WARNING, "PostgreSQL database not specified. Assuming asterisk\n");
tmp = "asteriskcdrdb";
}
}
if (!(tmp = ast_variable_retrieve(cfg, "global", "user"))) {
- ast_log(LOG_WARNING,"PostgreSQL database user not specified. Assuming asterisk\n");
+ ast_log(LOG_WARNING, "PostgreSQL database user not specified. Assuming asterisk\n");
tmp = "asterisk";
}
}
if (!(tmp = ast_variable_retrieve(cfg, "global", "password"))) {
- ast_log(LOG_WARNING,"PostgreSQL database password not specified. Assuming blank\n");
+ ast_log(LOG_WARNING, "PostgreSQL database password not specified. Assuming blank\n");
tmp = "";
}
return -1;
}
- if (!(tmp = ast_variable_retrieve(cfg,"global","port"))) {
- ast_log(LOG_WARNING,"PostgreSQL database port not specified. Using default 5432.\n");
+ if (!(tmp = ast_variable_retrieve(cfg, "global", "port"))) {
+ ast_log(LOG_WARNING, "PostgreSQL database port not specified. Using default 5432.\n");
tmp = "5432";
}
}
if (!(tmp = ast_variable_retrieve(cfg, "global", "table"))) {
- ast_log(LOG_WARNING,"CDR table not specified. Assuming cdr\n");
+ ast_log(LOG_WARNING, "CDR table not specified. Assuming cdr\n");
tmp = "cdr";
}
if (option_debug) {
if (ast_strlen_zero(pghostname)) {
- ast_debug(1, "cdr_pgsql: using default unix socket\n");
+ ast_debug(1, "using default unix socket\n");
} else {
- ast_debug(1, "cdr_pgsql: got hostname of %s\n", pghostname);
+ ast_debug(1, "got hostname of %s\n", pghostname);
}
- ast_debug(1, "cdr_pgsql: got port of %s\n", pgdbport);
- ast_debug(1, "cdr_pgsql: got user of %s\n", pgdbuser);
- ast_debug(1, "cdr_pgsql: got dbname of %s\n", pgdbname);
- ast_debug(1, "cdr_pgsql: got password of %s\n", pgpassword);
- ast_debug(1, "cdr_pgsql: got sql table name of %s\n", table);
+ ast_debug(1, "got port of %s\n", pgdbport);
+ ast_debug(1, "got user of %s\n", pgdbuser);
+ 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);
}
conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
result = PQexec(conn, sqlcmd);
if (PQresultStatus(result) != PGRES_TUPLES_OK) {
pgerror = PQresultErrorMessage(result);
- ast_log(LOG_ERROR, "cdr_pgsql: Failed to query database columns: %s\n", pgerror);
+ ast_log(LOG_ERROR, "Failed to query database columns: %s\n", pgerror);
PQclear(result);
unload_module();
return AST_MODULE_LOAD_DECLINE;
PQclear(result);
} else {
pgerror = PQerrorMessage(conn);
- ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s. CALLS WILL NOT BE LOGGED!!\n", pghostname);
- ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
+ ast_log(LOG_ERROR, "Unable to connect to database server %s. CALLS WILL NOT BE LOGGED!!\n", pghostname);
+ ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
connected = 0;
}