Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Logging to Query.php #66

Merged
merged 2 commits into from
Mar 7, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion classes/DataWarehouse/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Query
public $filterParameterDescriptions;
private $pdoparams;
private $pdoindex;
private $log;

/**
* Tracks whether or not role restrictions have been applied to this query.
Expand Down Expand Up @@ -118,7 +119,13 @@ public function __construct($realm_name,

$this->roleParameterDescriptions = array();
$this->filterParameterDescriptions = array();

$this->log = \CCR\Log::factory('xms.query', array(
'console' => false,
'db' => false,
'mail' => false,
'file' => LOG_DIR . '/query.log',
'fileLogLevel' => PEAR_LOG_DEBUG
));
}


Expand Down Expand Up @@ -229,6 +236,13 @@ public function execute($limit = 10000000)
{

$query_string = $this->getQueryString($limit);

$debug = filter_var(\xd_utilities\getConfiguration('general', 'sql_debug_mode'), FILTER_VALIDATE_BOOLEAN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter_var is broken in php 5.3 (which is our supported version). See issue #64 for a workaround. I have a function in the ETL\Utilities class but maybe it should be brought up into xd_utilities.

if ($debug == true) {
$class = get_class($this);
$this->log->debug(sprintf("%s: \n%s", $class, $query_string));
}

$time_start = microtime(true);
$results = DB::factory($this->_db_profile)->query($query_string, $this->pdoparams);

Expand Down