Skip to content
Snippets Groups Projects
Commit a32be680 authored by Prasad's avatar Prasad
Browse files

Fixes #1877: Improved calls to mem-cost function based on need in pquery

parent 4cb8ccaf
No related branches found
No related tags found
No related merge requests found
......@@ -357,8 +357,20 @@ class PearDatabase{
$this->executeSetNamesUTF8SQL();
$sql_start_time = microtime(true);
$params = $this->flatten_array($params);
if (is_array($params) && count($params) > 0) {
// flatten only when params has array inside.
$flatten_params = false;
foreach ($params as $val) {
if (is_array($val)) {
$flatten_params = true;
break;
}
}
if ($flatten_params) {
$params = $this->flatten_array($params);
}
if ($log->isDebugEnabled() && is_array($params) && count($params) > 0) {
$log->debug('Prepared sql query parameters : [' . implode(",", $params) . ']');
}
......
......@@ -76,6 +76,10 @@ class Logger {
public function warn($message) {}
public function error($message) {}
public function isDebugEnabled() {
return self::$logLevel == 100;
}
}
// Define extended version of Monolog Logger to support functions
......@@ -83,6 +87,16 @@ class MonologLoggerEx extends MonologLogger {
function fatal($message, $context = array()) {
$this->error($message, $context);
}
function isDebugEnabled() {
$debugLevel = false;
foreach ($this->getHandlers() as $handler) {
if ($handler->getLogLevel() == static::DEBUG) {
$debugLevel = true;
break;
}
}
return $debugLevel;
}
}
// Define a custom log formatter
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment