mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Add better logging to XML CDR
This commit is contained in:
@@ -37,7 +37,6 @@ if (!class_exists('xml_cdr')) {
|
||||
*/
|
||||
public $db;
|
||||
public $array;
|
||||
public $debug;
|
||||
public $fields;
|
||||
|
||||
/**
|
||||
@@ -95,13 +94,33 @@ if (!class_exists('xml_cdr')) {
|
||||
* cdr process logging
|
||||
*/
|
||||
public function log($message) {
|
||||
//save to file system (alternative to a syslog server)
|
||||
$fp = fopen($_SESSION['server']['temp']['dir'].'/xml_cdr.log', 'a+');
|
||||
if (!$fp) {
|
||||
return;
|
||||
|
||||
//save the log if enabled is true
|
||||
if ($_SESSION['log']['enabled']['boolean'] == 'true') {
|
||||
|
||||
//save the log to the php error log
|
||||
if ($_SESSION['log']['type']['text'] == 'error_log') {
|
||||
error_log($message);
|
||||
}
|
||||
fwrite($fp, $message);
|
||||
fclose($fp);
|
||||
|
||||
//save the log to the syslog server
|
||||
if ($_SESSION['log']['type']['text'] == 'syslog') {
|
||||
openlog("XML CDR", LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
||||
syslog(LOG_WARNING, $message);
|
||||
closelog();
|
||||
}
|
||||
|
||||
//save the log to the file system
|
||||
if ($_SESSION['log']['type']['text'] == 'file') {
|
||||
$fp = fopen($_SESSION['server']['temp']['dir'].'/xml_cdr.log', 'a+');
|
||||
if (!$fp) {
|
||||
return;
|
||||
}
|
||||
fwrite($fp, $message);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,8 +233,9 @@ if (!class_exists('xml_cdr')) {
|
||||
$database->app_uuid = '4a085c51-7635-ff03-f67b-86e834422848';
|
||||
$database->domain_uuid = $domain_uuid;
|
||||
$database->save($array, false);
|
||||
//$message = $database->message;
|
||||
//print_r($message);
|
||||
|
||||
//debug results
|
||||
$this->log(print_r($database->message, true));
|
||||
|
||||
//remove the temporary permission
|
||||
$p->delete("xml_cdr_add", "temp");
|
||||
@@ -255,7 +275,7 @@ if (!class_exists('xml_cdr')) {
|
||||
}
|
||||
catch(Exception $e) {
|
||||
echo $e->getMessage();
|
||||
//$this->log("\nfail loadxml: " . $e->getMessage() . "\n");
|
||||
$this->log("\nXML parsing error: " . $e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
//check for duplicate call uuid's
|
||||
@@ -479,7 +499,7 @@ if (!class_exists('xml_cdr')) {
|
||||
}
|
||||
|
||||
//send the domain name to the cdr log
|
||||
//$this->log("\ndomain_name is `$domain_name`; domain_uuid is '$domain_uuid'\n");
|
||||
//$this->log("\ndomain_name is `$domain_name`;\ndomain_uuid is '$domain_uuid'\n");
|
||||
|
||||
//get the domain_uuid with the domain_name
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
@@ -713,10 +733,9 @@ if (!class_exists('xml_cdr')) {
|
||||
}
|
||||
|
||||
//insert the values
|
||||
if ($this->debug) {
|
||||
//$time5_insert = microtime(true);
|
||||
//echo $sql."<br />\n";
|
||||
}
|
||||
//if ($this->debug) {
|
||||
// $time5_insert = microtime(true);
|
||||
//}
|
||||
try {
|
||||
$error = "false";
|
||||
//$this->db->exec($sql);
|
||||
@@ -737,9 +756,10 @@ if (!class_exists('xml_cdr')) {
|
||||
fwrite($fh, json_encode($xml));
|
||||
}
|
||||
fclose($fh);
|
||||
if ($this->debug) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
//debug info
|
||||
$this->log($e->getMessage());
|
||||
|
||||
$error = "true";
|
||||
}
|
||||
|
||||
@@ -764,11 +784,10 @@ if (!class_exists('xml_cdr')) {
|
||||
}
|
||||
unset($error);
|
||||
|
||||
//if ($this->debug) {
|
||||
//GLOBAL $insert_time,$insert_count;
|
||||
//$insert_time+=microtime(true)-$time5_insert; //add this current query.
|
||||
//$insert_count++;
|
||||
//}
|
||||
//debug
|
||||
//GLOBAL $insert_time,$insert_count;
|
||||
//$insert_time+=microtime(true)-$time5_insert; //add this current query.
|
||||
//$insert_count++;
|
||||
|
||||
} //if ($duplicate_uuid == false)
|
||||
} //function xml_array
|
||||
@@ -850,10 +869,9 @@ if (!class_exists('xml_cdr')) {
|
||||
*/
|
||||
public function post() {
|
||||
if (isset($_POST["cdr"])) {
|
||||
|
||||
//debug method
|
||||
if ($this->debug){
|
||||
print_r($_POST["cdr"]);
|
||||
}
|
||||
//$this->log($_POST["cdr"]);
|
||||
|
||||
//authentication for xml cdr http post
|
||||
if (!defined('STDIN')) {
|
||||
@@ -925,11 +943,12 @@ if (!class_exists('xml_cdr')) {
|
||||
}
|
||||
|
||||
//log the xml cdr
|
||||
//xml_cdr_log("process cdr via post\n");
|
||||
$this->log("HTTP POST\n");
|
||||
|
||||
//parse the xml and insert the data into the database
|
||||
$this->xml_array(0, $leg, $xml_string);
|
||||
$this->save();
|
||||
|
||||
}
|
||||
}
|
||||
//$this->post();
|
||||
|
||||
@@ -44,11 +44,9 @@
|
||||
ini_set('memory_limit', '256M');
|
||||
ini_set("precision", 6);
|
||||
|
||||
//import the call detail records
|
||||
//import the call detail records from HTTP POST or file system
|
||||
$cdr = new xml_cdr;
|
||||
//import from the FreeSWITCH POST
|
||||
$cdr->post();
|
||||
//import from the file system
|
||||
$cdr->read_files();
|
||||
|
||||
?>
|
||||
|
||||
@@ -453,6 +453,22 @@
|
||||
$apps[$x]['default_settings'][$y]['default_setting_value'] = "/var/cache/fusionpbx";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Location for the file cache.";
|
||||
$y++;
|
||||
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "31b60c5f-e501-4982-893b-b56ef4ef5b56";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_category'] = "log";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "enabled";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_value'] = "false";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Enable logging true or false.";
|
||||
$y++;
|
||||
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "81008738-aec1-4535-b451-29c25f213694";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_category'] = "log";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "type";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_value'] = "syslog";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Options: syslog, file";
|
||||
|
||||
//schema details
|
||||
$y=0;
|
||||
|
||||
Reference in New Issue
Block a user