change switch_console_printf to switch_log_printf in mod_cdr. Patch from MODAPP-6, thanks Marcel.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4920 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-04-12 18:14:30 +00:00
parent a483c238b9
commit 12c47bf96f
10 changed files with 92 additions and 82 deletions

View File

@ -24,6 +24,7 @@
* Contributor(s): * Contributor(s):
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This C++ source file describes the BaseCDR class that all other CDR classes inherit from. * Description: This C++ source file describes the BaseCDR class that all other CDR classes inherit from.
* It handles the bulk of the processing of data from the switch_channel_t objects. * It handles the bulk of the processing of data from the switch_channel_t objects.
@ -214,7 +215,7 @@ void BaseCDR::parse_channel_variables_xconfig(std::string& unparsed,std::list<st
{ {
if(fixed) if(fixed)
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Wildcards are not allow in the fixed chanvars list. Item removed.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Wildcards are not allow in the fixed chanvars list. Item removed.\n");
iItr = chanvarlist.erase(iItr); iItr = chanvarlist.erase(iItr);
} }
else else
@ -271,19 +272,19 @@ void BaseCDR::parse_channel_variables_xconfig(std::string& unparsed,std::list<st
sql_type = CDR_TINY; sql_type = CDR_TINY;
break; break;
default: default:
switch_console_printf(SWITCH_CHANNEL_LOG,"Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string). You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n",tempstring2.c_str(),tempstring.c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string). You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n", tempstring2.c_str(), tempstring.c_str());
sql_type = CDR_STRING; sql_type = CDR_STRING;
} }
} }
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string). You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n",tempstring2.c_str(),tempstring.c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string). You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n", tempstring2.c_str(), tempstring.c_str());
sql_type = CDR_STRING; sql_type = CDR_STRING;
} }
} }
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"No parameter set, for channel variable %s, using default type of string.\n",iItr->c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No parameter set, for channel variable %s, using default type of string.\n", iItr->c_str());
sql_type = CDR_STRING; sql_type = CDR_STRING;
tempstring = *iItr; tempstring = *iItr;
} }

View File

@ -24,6 +24,7 @@
* Contributor(s): * Contributor(s):
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This C++ source file describes the CDRContainer singleton object used by mod_cdr to control * Description: This C++ source file describes the CDRContainer singleton object used by mod_cdr to control
* the creation, processing, and destruction of various CDR logger objects. * the creation, processing, and destruction of various CDR logger objects.
@ -53,7 +54,7 @@ CDRContainer::CDRContainer(switch_memory_pool_t *module_pool)
newchannel = 0; newchannel = 0;
if (!(xml = switch_xml_open_cfg(configfile, &cfg, NULL))) if (!(xml = switch_xml_open_cfg(configfile, &cfg, NULL)))
switch_console_printf(SWITCH_CHANNEL_LOG,"open of %s failed\n", configfile); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", configfile);
else else
{ {
BaseRegistry& registry(BaseRegistry::get()); BaseRegistry& registry(BaseRegistry::get());
@ -89,7 +90,7 @@ CDRContainer::~CDRContainer()
ptr->disconnect(); ptr->disconnect();
} }
switch_console_printf(SWITCH_CHANNEL_LOG,"mod_cdr shutdown gracefully."); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mod_cdr shutdown gracefully.");
} }
#ifdef SWITCH_QUEUE_ENHANCED #ifdef SWITCH_QUEUE_ENHANCED
@ -225,7 +226,7 @@ void CDRContainer::add_cdr(switch_core_session_t *session)
basecdr_creator func = *it; basecdr_creator func = *it;
BaseCDR* newloggerobject = func(newchannel); BaseCDR* newloggerobject = func(newchannel);
switch_console_printf(SWITCH_CHANNEL_LOG,"Adding a new logger object to the queue.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Adding a new logger object to the queue.\n");
switch_queue_push(cdrqueue,newloggerobject); switch_queue_push(cdrqueue,newloggerobject);
} }
newchannel->callerprofile = newchannel->callerprofile->next; newchannel->callerprofile = newchannel->callerprofile->next;

View File

@ -24,6 +24,7 @@
* Contributor(s): * Contributor(s):
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This C++ source file describes the CsvCDR class that handles processing CDRs to a CSV format. * Description: This C++ source file describes the CsvCDR class that handles processing CDRs to a CSV format.
* This is the standard CSV module, and has a list of predefined variables to log out which can be * This is the standard CSV module, and has a list of predefined variables to log out which can be
@ -101,7 +102,7 @@ std::string CsvCDR::display_name = "CsvCDR - The simple comma separated values C
void CsvCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param) void CsvCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
{ {
switch_console_printf(SWITCH_CHANNEL_LOG, "CsvCDR::connect() - Loading configuration file.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CsvCDR::connect() - Loading configuration file.\n");
activated = 0; // Set it as inactive initially activated = 0; // Set it as inactive initially
connectionstate = 0; // Initialize it to false to show that we aren't yet connected. connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
@ -170,7 +171,7 @@ void CsvCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setting
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n",val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n", val);
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
} }
} }
@ -182,11 +183,11 @@ void CsvCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setting
if(outputfile.good()) if(outputfile.good())
{ {
activated = 1; activated = 1;
switch_console_printf(SWITCH_CHANNEL_LOG,"CsvCDR activated, log rotation will occur at or after %d MB\n",(int)(filesize_limit >> 20)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CsvCDR activated, log rotation will occur at or after %d MB\n", (int)(filesize_limit >> 20));
} }
} }
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"CsvCDR::connect(): You did not specify the minimum parameters for using this module. You must specify at least a path to have the records logged to.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CsvCDR::connect(): You did not specify the minimum parameters for using this module. You must specify at least a path to have the records logged to.\n");
} }
} }
@ -228,7 +229,7 @@ void CsvCDR::open_file()
outputfile.open(filename.c_str(),std::ios_base::app|std::ios_base::binary); outputfile.open(filename.c_str(),std::ios_base::app|std::ios_base::binary);
if(outputfile.fail()) if(outputfile.fail())
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Could not open the CSV file %s . CsvCDR logger will not be functional until this is resolved and a reload is issued. Failbit is set to %d.\n",filename.c_str(),outputfile.fail()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open the CSV file %s . CsvCDR logger will not be functional until this is resolved and a reload is issued. Failbit is set to %d.\n", filename.c_str(), outputfile.fail());
activated = 0; activated = 0;
} }
else else
@ -332,7 +333,7 @@ void CsvCDR::disconnect()
chanvars_fixed_list.clear(); chanvars_fixed_list.clear();
chanvars_supp_list.clear(); chanvars_supp_list.clear();
connectionstate = 0; connectionstate = 0;
switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down CsvCDR... Done!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down CsvCDR... Done!\n");
} }
AUTO_REGISTER_BASECDR(CsvCDR); AUTO_REGISTER_BASECDR(CsvCDR);

View File

@ -28,6 +28,7 @@
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Bret McDanel <trixter AT 0xdecafbad.com> * Bret McDanel <trixter AT 0xdecafbad.com>
* Anthony Minessale II <anthmct@yahoo.com> * Anthony Minessale II <anthmct@yahoo.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This C++ source file describes the CurlCDR class that handles processing CDRs to HTTP endpoint. * Description: This C++ source file describes the CurlCDR class that handles processing CDRs to HTTP endpoint.
* This is the standard Curl module, and has a list of predefined variables to log out which can be * This is the standard Curl module, and has a list of predefined variables to log out which can be
@ -106,14 +107,14 @@ std::string CurlCDR::postdata;
void CurlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param) void CurlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
{ {
switch_console_printf(SWITCH_CHANNEL_LOG, "CurlCDR::connect() - Loading configuration file.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CurlCDR::connect() - Loading configuration file.\n");
activated = 0; // Set it as inactive initially activated = 0; // Set it as inactive initially
connectionstate = 0; // Initialize it to false to show that we aren't yet connected. connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
switch_console_printf(SWITCH_CHANNEL_LOG,"Checking to see if curlcdr is valid\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking to see if curlcdr is valid\n");
if ((settings = switch_xml_child(cfg, "curlcdr"))) if ((settings = switch_xml_child(cfg, "curlcdr")))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"curlcdr appears to be!!!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "curlcdr appears to be!!!\n");
int count_config_params = 0; // Need to make sure all params are set before we load int count_config_params = 0; // Need to make sure all params are set before we load
for (param = switch_xml_child(settings, "param"); param; param = param->next) for (param = switch_xml_child(settings, "param"); param; param = param->next)
{ {
@ -168,7 +169,7 @@ void CurlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settin
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n",val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n", val);
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
} }
} }
@ -179,13 +180,13 @@ void CurlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settin
if(strlen(gateway_url)) if(strlen(gateway_url))
{ {
activated = 1; activated = 1;
switch_console_printf(SWITCH_CHANNEL_LOG,"CurlCDR activated"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CurlCDR activated");
} }
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"CurlCDR::connect(): You must specify a gateway_url to have the records logged to.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CurlCDR::connect(): You must specify a gateway_url to have the records logged to.\n");
} }
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"CurlCDR::connect(): You did not specify the minimum parameters for using this module. You must specify at least a gateway_url to have the records logged to.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CurlCDR::connect(): You did not specify the minimum parameters for using this module. You must specify at least a gateway_url to have the records logged to.\n");
} }
} }
@ -370,7 +371,7 @@ void CurlCDR::disconnect()
chanvars_fixed_list.clear(); chanvars_fixed_list.clear();
chanvars_supp_list.clear(); chanvars_supp_list.clear();
connectionstate = 0; connectionstate = 0;
switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down CurlCDR... Done!"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down CurlCDR... Done!");
} }
AUTO_REGISTER_BASECDR(CurlCDR); AUTO_REGISTER_BASECDR(CurlCDR);

View File

@ -24,6 +24,7 @@
* Contributor(s): * Contributor(s):
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This source file describes the most basic portions of the CDR module. These are the functions * Description: This source file describes the most basic portions of the CDR module. These are the functions
* and structures that the Freeswitch core looks for when opening up the DSO file to create the load, shutdown * and structures that the Freeswitch core looks for when opening up the DSO file to create the load, shutdown
@ -130,7 +131,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS)
{ {
switch_console_printf(SWITCH_CHANNEL_LOG, "OH OH - Can't swim, no pool\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH - Can't swim, no pool\n");
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
@ -144,7 +145,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void) SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
{ {
RUNNING = 1; RUNNING = 1;
switch_console_printf(SWITCH_CHANNEL_LOG, "mod_cdr made it to runtime. Wee!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mod_cdr made it to runtime. Wee!\n");
newcdrcontainer->process_records(); newcdrcontainer->process_records();
return RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TERM; return RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TERM;

View File

@ -24,6 +24,7 @@
* Contributor(s): * Contributor(s):
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This C++ source file describes the MysqlCDR class which handles formatting a CDR out to * Description: This C++ source file describes the MysqlCDR class which handles formatting a CDR out to
* a MySQL 4.1.x or greater server using prepared statements. * a MySQL 4.1.x or greater server using prepared statements.
@ -183,7 +184,7 @@ void MysqlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setti
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n",val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n", val);
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
} }
} }
@ -192,7 +193,7 @@ void MysqlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setti
if (count_config_params==4) if (count_config_params==4)
activated = 1; activated = 1;
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"You did not specify the minimum parameters for using this module. You must specify a hostname, username, password, and database to use MysqlCDR. You only supplied %d parameters.\n",count_config_params); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You did not specify the minimum parameters for using this module. You must specify a hostname, username, password, and database to use MysqlCDR. You only supplied %d parameters.\n", count_config_params);
if(activated) if(activated)
{ {
@ -241,7 +242,7 @@ void MysqlCDR::connect_to_database()
if(mysql_real_connect(conn,hostname,username,password,dbname,0,NULL,0) == NULL) if(mysql_real_connect(conn,hostname,username,password,dbname,0,NULL,0) == NULL)
{ {
const char *error1 = mysql_error(conn); const char *error1 = mysql_error(conn);
switch_console_printf(SWITCH_CHANNEL_LOG,"Cannot connect to MySQL Server. The error was: %s\n",error1); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot connect to MySQL Server. The error was: %s\n", error1);
} }
else else
connectionstate = 1; connectionstate = 1;
@ -446,7 +447,7 @@ bool MysqlCDR::process_record()
break; break;
} }
default: default:
switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "We should not get to this point in this switch/case statement.\n");
} }
i++; i++;
} }
@ -466,13 +467,13 @@ bool MysqlCDR::process_record()
case CR_SERVER_GONE_ERROR: case CR_SERVER_GONE_ERROR:
case CR_SERVER_LOST: case CR_SERVER_LOST:
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"We lost connection to the MySQL server. Trying to reconnect.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We lost connection to the MySQL server. Trying to reconnect.\n");
connect_to_database(); connect_to_database();
break; break;
} }
default: default:
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"We have encountered an unknown error when pinging the MySQL server. Attempting to reconnect anyways.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We have encountered an unknown error when pinging the MySQL server. Attempting to reconnect anyways.\n");
connect_to_database(); connect_to_database();
} }
} }
@ -485,10 +486,10 @@ bool MysqlCDR::process_record()
if(mysql_stmt_error_code != 0) if(mysql_stmt_error_code != 0)
{ {
errorstate = 1; errorstate = 1;
switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Statement executed? Error: %d\n",mysql_stmt_error_code); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MysqlCDR::process_record() - Statement executed? Error: %d\n", mysql_stmt_error_code);
const char* mysql_stmt_error_string = mysql_stmt_error(stmt); const char* mysql_stmt_error_string = mysql_stmt_error(stmt);
switch_console_printf(SWITCH_CHANNEL_LOG,"MySQL encountered error: %s\n",mysql_stmt_error_string); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MySQL encountered error: %s\n", mysql_stmt_error_string);
} }
else else
errorstate = 0; errorstate = 0;
@ -585,7 +586,7 @@ bool MysqlCDR::process_record()
break; break;
} }
default: default:
switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "We should not get to this point in this switch/case statement.\n");
} }
bool* tempbool = (bool*) temp_chanvars_holder.front(); bool* tempbool = (bool*) temp_chanvars_holder.front();

View File

@ -24,6 +24,7 @@
* Contributor(s): * Contributor(s):
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This C++ source file describes the OdbcCDR class which handles formatting a CDR out to * Description: This C++ source file describes the OdbcCDR class which handles formatting a CDR out to
* an ODBC backend using prepared statements. * an ODBC backend using prepared statements.
@ -201,7 +202,7 @@ void OdbcCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settin
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n",val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n", val);
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
} }
} }
@ -216,7 +217,7 @@ void OdbcCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settin
if (count_config_params==4) if (count_config_params==4)
activated = 1; activated = 1;
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"You did not specify the minimum parameters for using this module. You must specify a DSN,hostname, username, password, and database to use OdbcCDR. You only supplied %d parameters.\n",count_config_params); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You did not specify the minimum parameters for using this module. You must specify a DSN,hostname, username, password, and database to use OdbcCDR. You only supplied %d parameters.\n", count_config_params);
if(activated) if(activated)
{ {
@ -275,7 +276,7 @@ void OdbcCDR::connect_to_database()
ODBC_res = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &ODBC_env); ODBC_res = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &ODBC_env);
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Error allocating a new ODBC handle.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error allocating a new ODBC handle.\n");
connectionstate = 0; connectionstate = 0;
} }
} }
@ -284,7 +285,7 @@ void OdbcCDR::connect_to_database()
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Error with ODBCSetEnv\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error with ODBCSetEnv\n");
SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env); SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
connectionstate = 0; connectionstate = 0;
} }
@ -293,7 +294,7 @@ void OdbcCDR::connect_to_database()
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Error AllocHDB %d\n",ODBC_res); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error AllocHDB %d\n", ODBC_res);
SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env); SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
connectionstate = 0; connectionstate = 0;
} }
@ -306,14 +307,14 @@ void OdbcCDR::connect_to_database()
ODBC_res = SQLConnect(ODBC_con, (SQLCHAR*)dsn, SQL_NTS, (SQLCHAR*)username, SQL_NTS, (SQLCHAR*)password, SQL_NTS); ODBC_res = SQLConnect(ODBC_con, (SQLCHAR*)dsn, SQL_NTS, (SQLCHAR*)username, SQL_NTS, (SQLCHAR*)password, SQL_NTS);
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Error connecting to the ODBC database on %d\n",ODBC_res); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error connecting to the ODBC database on %d\n", ODBC_res);
SQLFreeHandle(SQL_HANDLE_DBC, ODBC_con); SQLFreeHandle(SQL_HANDLE_DBC, ODBC_con);
SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env); SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
connectionstate = 0; connectionstate = 0;
} }
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Connected to %s\n", dsn); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connected to %s\n", dsn);
connectionstate = 1; connectionstate = 1;
} }
@ -325,7 +326,7 @@ void OdbcCDR::connect_to_database()
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Failure in allocating a prepared statement %d\n", ODBC_res); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure in allocating a prepared statement %d\n", ODBC_res);
SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt); SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
} }
@ -333,7 +334,7 @@ void OdbcCDR::connect_to_database()
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Error in preparing a statement: %d\n", ODBC_res); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error in preparing a statement: %d\n", ODBC_res);
SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt); SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
} }
@ -343,7 +344,7 @@ void OdbcCDR::connect_to_database()
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Failure in allocating a prepared statement %d\n", ODBC_res); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure in allocating a prepared statement %d\n", ODBC_res);
SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_chanvars); SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_chanvars);
} }
@ -351,7 +352,7 @@ void OdbcCDR::connect_to_database()
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Error in preparing a statement: %d\n", ODBC_res); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error in preparing a statement: %d\n", ODBC_res);
SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt); SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
} }
} }
@ -360,7 +361,7 @@ void OdbcCDR::connect_to_database()
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Failure in allocating a prepared statement %d\n", ODBC_res); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure in allocating a prepared statement %d\n", ODBC_res);
SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_ping); SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_ping);
} }
@ -368,7 +369,7 @@ void OdbcCDR::connect_to_database()
if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Error in preparing a statement: %d\n", ODBC_res); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error in preparing a statement: %d\n", ODBC_res);
SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_ping); SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_ping);
} }
@ -400,7 +401,7 @@ bool OdbcCDR::process_record()
if(ODBC_res != SQL_SUCCESS && ODBC_res != SQL_SUCCESS_WITH_INFO) if(ODBC_res != SQL_SUCCESS && ODBC_res != SQL_SUCCESS_WITH_INFO)
{ {
// Try to reconnect and reprepare // Try to reconnect and reprepare
switch_console_printf(SWITCH_CHANNEL_LOG,"Error pinging the ODBC backend. Attempt #%d to reconnect.\n",count+1); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error pinging the ODBC backend. Attempt #%d to reconnect.\n", count+1);
connect_to_database(); connect_to_database();
} }
} }
@ -502,7 +503,7 @@ bool OdbcCDR::process_record()
break; break;
} }
default: default:
switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "We should not get to this point in this switch/case statement.\n");
} }
i++; i++;
} }
@ -585,7 +586,7 @@ bool OdbcCDR::process_record()
break; break;
} }
default: default:
switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "We should not get to this point in this switch/case statement.\n");
} }
} }
} }

View File

@ -24,6 +24,7 @@
* Contributor(s): * Contributor(s):
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This C++ source file describes the PddCDR class which handles formatting a CDR out to * Description: This C++ source file describes the PddCDR class which handles formatting a CDR out to
* individual text files in a Perl Data Dumper format. * individual text files in a Perl Data Dumper format.
@ -101,7 +102,7 @@ std::string PddCDR::display_name = "PddCDR - Perl Data Dumper CDR logger";
void PddCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param) void PddCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
{ {
switch_console_printf(SWITCH_CHANNEL_LOG, "PddCDR::connect() - Loading configuration file.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PddCDR::connect() - Loading configuration file.\n");
activated = 0; // Set it as inactive initially activated = 0; // Set it as inactive initially
connectionstate = 0; // Initialize it to false to show that we aren't yet connected. connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
@ -135,11 +136,11 @@ void PddCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setting
} }
else if (!strcmp(var, "chanvars_fixed")) else if (!strcmp(var, "chanvars_fixed"))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"PddCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "PddCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n");
} }
else if (!strcmp(var, "chanvars_supp")) else if (!strcmp(var, "chanvars_supp"))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"PddCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "PddCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n");
} }
else if(!strcmp(var,"timezone")) else if(!strcmp(var,"timezone"))
{ {
@ -149,7 +150,7 @@ void PddCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setting
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n",val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n", val);
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
} }
} }
@ -158,7 +159,7 @@ void PddCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setting
if(count_config_params > 0) if(count_config_params > 0)
activated = 1; activated = 1;
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"PddCDR::connect(): You did not specify the minimum parameters for using this module. You must specify at least a path to have the records logged to.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PddCDR::connect(): You did not specify the minimum parameters for using this module. You must specify at least a path to have the records logged to.\n");
} }
} }
@ -168,7 +169,7 @@ bool PddCDR::process_record()
bool retval = 0; bool retval = 0;
if(!outputfile) if(!outputfile)
switch_console_printf(SWITCH_CHANNEL_LOG, "PddCDR::process_record(): Unable to open file %s to commit the call record to. Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PddCDR::process_record(): Unable to open file %s to commit the call record to. Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str());
else else
{ {
// Format the call record and proceed from here... // Format the call record and proceed from here...
@ -247,7 +248,7 @@ void PddCDR::disconnect()
logchanvars = 0; logchanvars = 0;
outputfile_path.clear(); outputfile_path.clear();
chanvars_supp_list.clear(); chanvars_supp_list.clear();
switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down PddCDR... Done!"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down PddCDR... Done!");
} }
AUTO_REGISTER_BASECDR(PddCDR); AUTO_REGISTER_BASECDR(PddCDR);

View File

@ -24,6 +24,7 @@
* Contributor(s): * Contributor(s):
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: his C++ header file describes the SqliteCDR class which handles formatting a CDR out to * Description: his C++ header file describes the SqliteCDR class which handles formatting a CDR out to
* a SQLite database using prepared statements. * a SQLite database using prepared statements.
@ -141,7 +142,7 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
use_utc_time = 0; use_utc_time = 0;
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n",val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n", val);
use_utc_time = 0; use_utc_time = 0;
} }
} }
@ -150,7 +151,7 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
if (count_config_params==1) if (count_config_params==1)
activated = 1; activated = 1;
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"You did not specify the minimum parameters for using this module. You must specify an explicit (complete) path to the location of the database file in order to use SqliteCDR.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You did not specify the minimum parameters for using this module. You must specify an explicit (complete) path to the location of the database file in order to use SqliteCDR.\n");
if(activated) if(activated)
{ {
@ -192,7 +193,7 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
if(sql_rc != SWITCH_CORE_DB_OK) if(sql_rc != SWITCH_CORE_DB_OK)
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error opening database filename %s. The error was: %s. SqliteCDR logging has been disabled until the problem is resolved and modcdr_reload is initiated.\n",db_filename.c_str(),switch_core_db_errmsg(db)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There was an error opening database filename %s. The error was: %s. SqliteCDR logging has been disabled until the problem is resolved and modcdr_reload is initiated.\n", db_filename.c_str(), switch_core_db_errmsg(db));
activated = 0; activated = 0;
switch_core_db_close(db); switch_core_db_close(db);
} }
@ -223,13 +224,13 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
} }
} }
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error in executing query %s: The error was %s.\n",sql_query_check_tables,errormessage); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There was an error in executing query %s: The error was %s.\n", sql_query_check_tables, errormessage);
switch_core_db_free_table(result); switch_core_db_free_table(result);
if(!temp_sql_tables["freeswitchcdr"]) if(!temp_sql_tables["freeswitchcdr"])
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the freeswitchcdr table in the SQLite mod_cdr database file.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating the freeswitchcdr table in the SQLite mod_cdr database file.\n");
// Must create the missing freeswitchcdr table. // Must create the missing freeswitchcdr table.
char sql_query_create_freeswitchcdr[] = "CREATE TABLE freeswitchcdr (\n" char sql_query_create_freeswitchcdr[] = "CREATE TABLE freeswitchcdr (\n"
"callid INTEGER PRIMARY KEY AUTOINCREMENT,\n" "callid INTEGER PRIMARY KEY AUTOINCREMENT,\n"
@ -262,7 +263,7 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
if(!temp_sql_tables["chanvars"]) if(!temp_sql_tables["chanvars"])
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the chanvars table in the SQLite mod_cdr database file.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating the chanvars table in the SQLite mod_cdr database file.\n");
// Must create the missing chanvars table. // Must create the missing chanvars table.
char sql_query_create_chanvars[] = "CREATE TABLE chanvars (\n" char sql_query_create_chanvars[] = "CREATE TABLE chanvars (\n"
"callid INTEGER default 0,\n" "callid INTEGER default 0,\n"
@ -321,13 +322,13 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
tempstring2 = resultstring.substr(i,(j-i)); tempstring2 = resultstring.substr(i,(j-i));
freeswitchcdr_columns[tempstring1] = tempstring2; freeswitchcdr_columns[tempstring1] = tempstring2;
// switch_console_printf(SWITCH_CHANNEL_LOG,"tempstring1 = %s, tempstring2 = %s\n",tempstring1.c_str(),tempstring2.c_str()); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tempstring1 = %s, tempstring2 = %s\n", tempstring1.c_str(), tempstring2.c_str());
if(resultstring.find('\n',j+1) == (j+1)) if(resultstring.find('\n',j+1) == (j+1))
j++; j++;
i = j+1; i = j+1;
} }
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"There has been a parsing problem with the freeswitchcdr schema.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There has been a parsing problem with the freeswitchcdr schema.\n");
} }
} }
} }
@ -346,9 +347,9 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
case CDR_TINY: case CDR_TINY:
if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end()) if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
{ {
//switch_console_printf(SWITCH_CHANNEL_LOG,"freeswitchcdr_columns[%s] == %s.\n",iItr->c_str(),freeswitchcdr_columns[*iItr].c_str()); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "freeswitchcdr_columns[%s] == %s.\n", iItr->c_str(), freeswitchcdr_columns[*iItr].c_str());
if(freeswitchcdr_columns[*iItr].find("INTEGER",0) == std::string::npos) if(freeswitchcdr_columns[*iItr].find("INTEGER",0) == std::string::npos)
switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of an INTEGER type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of an INTEGER type. This is not necessarily fatal, but may result in unexpected behavior.\n", iItr->c_str());
} }
else else
freeswitchcdr_add_columns[*iItr] = "INTEGER"; freeswitchcdr_add_columns[*iItr] = "INTEGER";
@ -357,7 +358,7 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end()) if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
{ {
if(freeswitchcdr_columns[*iItr].find("REAL",0) == std::string::npos) if(freeswitchcdr_columns[*iItr].find("REAL",0) == std::string::npos)
switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a REAL type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a REAL type. This is not necessarily fatal, but may result in unexpected behavior.\n", iItr->c_str());
} }
else else
freeswitchcdr_add_columns[*iItr] = "REAL"; freeswitchcdr_add_columns[*iItr] = "REAL";
@ -367,19 +368,19 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end()) if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
{ {
if(freeswitchcdr_columns[*iItr].find("TEXT",0) == std::string::npos) if(freeswitchcdr_columns[*iItr].find("TEXT",0) == std::string::npos)
switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a TEXT type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a TEXT type. This is not necessarily fatal, but may result in unexpected behavior.\n", iItr->c_str());
} }
else else
freeswitchcdr_add_columns[*iItr] = "TEXT"; freeswitchcdr_add_columns[*iItr] = "TEXT";
break; break;
default: default:
switch_console_printf(SWITCH_CHANNEL_LOG,"Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n");
} }
} }
if(freeswitchcdr_add_columns.size()) if(freeswitchcdr_add_columns.size())
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Updating the freeswitchcdr table schema.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Updating the freeswitchcdr table schema.\n");
std::string tempsql_freeswitchcdr_alter_table = "ALTER TABLE freeswitchcdr ADD "; std::string tempsql_freeswitchcdr_alter_table = "ALTER TABLE freeswitchcdr ADD ";
std::map<std::string, std::string>::iterator iItr, iEnd; std::map<std::string, std::string>::iterator iItr, iEnd;
for(iItr = freeswitchcdr_add_columns.begin(), iEnd = freeswitchcdr_add_columns.end(); iItr != iEnd; iItr++) for(iItr = freeswitchcdr_add_columns.begin(), iEnd = freeswitchcdr_add_columns.end(); iItr != iEnd; iItr++)
@ -388,7 +389,7 @@ void SqliteCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& sett
sql_query_freeswitchcdr_alter_table.append(iItr->first); sql_query_freeswitchcdr_alter_table.append(iItr->first);
sql_query_freeswitchcdr_alter_table.append(" "); sql_query_freeswitchcdr_alter_table.append(" ");
sql_query_freeswitchcdr_alter_table.append(iItr->second); sql_query_freeswitchcdr_alter_table.append(iItr->second);
switch_console_printf(SWITCH_CHANNEL_LOG,"Updating the freeswitchcdr table with the following SQL command: %s.\n",sql_query_freeswitchcdr_alter_table.c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Updating the freeswitchcdr table with the following SQL command: %s.\n", sql_query_freeswitchcdr_alter_table.c_str());
switch_core_db_exec(db, sql_query_freeswitchcdr_alter_table.c_str(), NULL, NULL, NULL); switch_core_db_exec(db, sql_query_freeswitchcdr_alter_table.c_str(), NULL, NULL, NULL);
} }
} }
@ -514,7 +515,7 @@ bool SqliteCDR::process_record()
break; break;
} }
default: default:
switch_console_printf(SWITCH_CHANNEL_LOG,"Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n");
} }
} }
} }
@ -525,7 +526,7 @@ bool SqliteCDR::process_record()
if(sql_rc == SWITCH_CORE_DB_BUSY) if(sql_rc == SWITCH_CORE_DB_BUSY)
sql_rc = switch_core_db_step(stmt); sql_rc = switch_core_db_step(stmt);
else if (sql_rc == SWITCH_CORE_DB_ERROR || sql_rc == SWITCH_CORE_DB_MISUSE) else if (sql_rc == SWITCH_CORE_DB_ERROR || sql_rc == SWITCH_CORE_DB_MISUSE)
switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt. The error was: %s\n",switch_core_db_errmsg(db)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There was an error executing switch_core_db_step on SqliteCDR::stmt. The error was: %s\n", switch_core_db_errmsg(db));
} }
sql_rc = switch_core_db_reset(stmt); sql_rc = switch_core_db_reset(stmt);
@ -546,7 +547,7 @@ bool SqliteCDR::process_record()
if(sql_rc == SWITCH_CORE_DB_BUSY) if(sql_rc == SWITCH_CORE_DB_BUSY)
sql_rc = switch_core_db_step(stmt_chanvars); sql_rc = switch_core_db_step(stmt_chanvars);
else if (sql_rc == SWITCH_CORE_DB_ERROR || sql_rc == SWITCH_CORE_DB_MISUSE) else if (sql_rc == SWITCH_CORE_DB_ERROR || sql_rc == SWITCH_CORE_DB_MISUSE)
switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt_chanvars. The error was: %s\n",switch_core_db_errmsg(db)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There was an error executing switch_core_db_step on SqliteCDR::stmt_chanvars. The error was: %s\n", switch_core_db_errmsg(db));
} }
switch_core_db_reset(stmt_chanvars); switch_core_db_reset(stmt_chanvars);

View File

@ -25,6 +25,7 @@
* *
* Yossi Neiman <freeswitch AT cartissolutions.com> * Yossi Neiman <freeswitch AT cartissolutions.com>
* Ken Rice of Asteria Solutions Group, INC <ken AT asteriasgi.com> * Ken Rice of Asteria Solutions Group, INC <ken AT asteriasgi.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* *
* Description: This C++ source file describes the XmlCDR class which handles formatting a CDR out to * Description: This C++ source file describes the XmlCDR class which handles formatting a CDR out to
* individual text files in a XML format. * individual text files in a XML format.
@ -103,7 +104,7 @@ std::string XmlCDR::display_name = "XmlCDR - The rough implementation of XML CDR
void XmlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param) void XmlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
{ {
switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::connect() - Loading configuration file.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "XmlCDR::connect() - Loading configuration file.\n");
activated = 0; // Set it as inactive initially activated = 0; // Set it as inactive initially
connectionstate = 0; // Initialize it to false to show that we aren't yet connected. connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
@ -137,11 +138,11 @@ void XmlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setting
} }
else if (!strcmp(var, "chanvars_fixed")) else if (!strcmp(var, "chanvars_fixed"))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"XmlCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XmlCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n");
} }
else if (!strcmp(var, "chanvars_supp")) else if (!strcmp(var, "chanvars_supp"))
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"XmlCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XmlCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format. Please use the setting parameter of \"chanvars\" instead and try again.\n");
} }
else if(!strcmp(var,"timezone")) else if(!strcmp(var,"timezone"))
{ {
@ -151,7 +152,7 @@ void XmlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setting
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
else else
{ {
switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n",val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone. Possible values are utc and local. You entered: %s\nDefaulting to local.\n", val);
convert_time = switch_time_exp_lt; convert_time = switch_time_exp_lt;
} }
} }
@ -160,7 +161,7 @@ void XmlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& setting
if(count_config_params > 0) if(count_config_params > 0)
activated = 1; activated = 1;
else else
switch_console_printf(SWITCH_CHANNEL_LOG,"XmlCDR::connect(): You did not specify the minimum parameters for using this module. You must specify at least a path to have the records logged to.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XmlCDR::connect(): You did not specify the minimum parameters for using this module. You must specify at least a path to have the records logged to.\n");
} }
} }
@ -170,10 +171,10 @@ bool XmlCDR::process_record()
outputfile.open(outputfile_name.c_str()); outputfile.open(outputfile_name.c_str());
if(!outputfile) if(!outputfile)
switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record(): Unable to open file %s to commit the call record to. Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XmlCDR::process_record(): Unable to open file %s to commit the call record to. Invalid path name, invalid permissions, or no space available?\n", outputfile_name.c_str());
else else
{ {
//switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record(): Preping the CDR to %s.\n",outputfile_name.c_str()); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "XmlCDR::process_record(): Preping the CDR to %s.\n", outputfile_name.c_str());
// Format the call record and proceed from here... // Format the call record and proceed from here...
outputfile << "<?xml version=\"1.0\"?>" << std::endl; outputfile << "<?xml version=\"1.0\"?>" << std::endl;
outputfile << "<document type=\"freeswitch-cdr/xml\">" << std::endl; outputfile << "<document type=\"freeswitch-cdr/xml\">" << std::endl;
@ -215,7 +216,7 @@ bool XmlCDR::process_record()
} }
outputfile << "\t</chanvars>" << std::endl << "</document>" << std::endl << std::endl; outputfile << "\t</chanvars>" << std::endl << "</document>" << std::endl << std::endl;
//switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record(): Dumping the CDR to %s.\n",outputfile_name.c_str()); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "XmlCDR::process_record(): Dumping the CDR to %s.\n", outputfile_name.c_str());
retval = 1; retval = 1;
} }
@ -249,7 +250,7 @@ void XmlCDR::disconnect()
logchanvars = 0; logchanvars = 0;
outputfile_path.clear(); outputfile_path.clear();
chanvars_supp_list.clear(); chanvars_supp_list.clear();
switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down XmlCDR... Done!"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down XmlCDR... Done!");
} }
AUTO_REGISTER_BASECDR(XmlCDR); AUTO_REGISTER_BASECDR(XmlCDR);