Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CRM_Core_Error::debug_var() should have a priority arg.
Browse files Browse the repository at this point in the history
mfb committed Aug 9, 2019
1 parent 920cc06 commit 2b3a163
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions CRM/Core/Error.php
Original file line number Diff line number Diff line change
@@ -232,7 +232,7 @@ public static function handle($pearError) {
$errorDetails = CRM_Core_Error::debug('', $error, FALSE);
$template->assign_by_ref('errorDetails', $errorDetails);

CRM_Core_Error::debug_var('Fatal Error Details', $error);
CRM_Core_Error::debug_var('Fatal Error Details', $error, TRUE, TRUE, '', PEAR_LOG_ERR);
CRM_Core_Error::backtrace('backTrace', TRUE);

if ($config->initialized) {
@@ -339,7 +339,7 @@ public static function fatal($message = NULL, $code = NULL, $email = NULL) {

if (self::$modeException) {
// CRM-11043
CRM_Core_Error::debug_var('Fatal Error Details', $vars);
CRM_Core_Error::debug_var('Fatal Error Details', $vars, TRUE, TRUE, '', PEAR_LOG_ERR);
CRM_Core_Error::backtrace('backTrace', TRUE);

$details = 'A fatal error was triggered';
@@ -381,7 +381,7 @@ function_exists($config->fatalErrorHandler)
self::backtrace();
}

CRM_Core_Error::debug_var('Fatal Error Details', $vars);
CRM_Core_Error::debug_var('Fatal Error Details', $vars, TRUE, TRUE, '', PEAR_LOG_ERR);
CRM_Core_Error::backtrace('backTrace', TRUE);

// If we are in an ajax callback, format output appropriately
@@ -421,7 +421,7 @@ public static function handleUnhandledException($exception) {
}
catch (Exception $other) {
// if the exception-handler generates an exception, then that sucks! oh, well. carry on.
CRM_Core_Error::debug_var('handleUnhandledException_nestedException', self::formatTextException($other));
CRM_Core_Error::debug_var('handleUnhandledException_nestedException', self::formatTextException($other), TRUE, TRUE, '', PEAR_LOG_ERR);
}
$config = CRM_Core_Config::singleton();
$vars = [
@@ -459,7 +459,7 @@ function_exists($config->fatalErrorHandler)
// Case C: Default error handler

// log to file
CRM_Core_Error::debug_var('Fatal Error Details', $vars, FALSE);
CRM_Core_Error::debug_var('Fatal Error Details', $vars, FALSE, TRUE, '', PEAR_LOG_ERR);
CRM_Core_Error::backtrace('backTrace', TRUE);

// print to screen
@@ -544,14 +544,16 @@ public static function debug($name, $variable = NULL, $log = TRUE, $html = TRUE,
* Log or return the output?
* @param string $prefix
* Prefix for output logfile.
* @param int $priority
* The log priority level.
*
* @return string
* The generated output
*
* @see CRM_Core_Error::debug()
* @see CRM_Core_Error::debug_log_message()
*/
public static function debug_var($variable_name, $variable, $print = TRUE, $log = TRUE, $prefix = '') {
public static function debug_var($variable_name, $variable, $print = TRUE, $log = TRUE, $prefix = '', $level = PEAR_LOG_INFO) {
// check if variable is set
if (!isset($variable)) {
$out = "\$$variable_name is not set";
@@ -574,7 +576,7 @@ public static function debug_var($variable_name, $variable, $print = TRUE, $log
reset($variable);
}
}
return self::debug_log_message($out, FALSE, $prefix);
return self::debug_log_message($out, FALSE, $prefix, $level);
}

/**
@@ -635,7 +637,7 @@ public static function debug_query($string) {
CRM_Core_Error::backtrace($string, TRUE);
}
elseif (CIVICRM_DEBUG_LOG_QUERY) {
CRM_Core_Error::debug_var('Query', $string, TRUE, TRUE, 'sql_log');
CRM_Core_Error::debug_var('Query', $string, TRUE, TRUE, 'sql_log', PEAR_LOG_DEBUG);
}
}
}
@@ -647,7 +649,7 @@ public static function debug_query($string) {
*/
public static function debug_query_result($query) {
$results = CRM_Core_DAO::executeQuery($query)->fetchAll();
CRM_Core_Error::debug_var('dao result', ['query' => $query, 'results' => $results]);
CRM_Core_Error::debug_var('dao result', ['query' => $query, 'results' => $results], TRUE, TRUE, '', PEAR_LOG_DEBUG);
}

/**
@@ -731,7 +733,7 @@ public static function backtrace($msg = 'backTrace', $log = FALSE) {
CRM_Core_Error::debug($msg, $message);
}
else {
CRM_Core_Error::debug_var($msg, $message);
CRM_Core_Error::debug_var($msg, $message, TRUE, TRUE, '', PEAR_LOG_DEBUG);
}
}

@@ -948,7 +950,7 @@ public static function reset() {
* @throws PEAR_Exception
*/
public static function exceptionHandler($pearError) {
CRM_Core_Error::debug_var('Fatal Error Details', self::getErrorDetails($pearError));
CRM_Core_Error::debug_var('Fatal Error Details', self::getErrorDetails($pearError), TRUE, TRUE, '', PEAR_LOG_ERR);
CRM_Core_Error::backtrace('backTrace', TRUE);
throw new PEAR_Exception($pearError->getMessage(), $pearError);
}
@@ -962,7 +964,7 @@ public static function exceptionHandler($pearError) {
* $obj
*/
public static function nullHandler($obj) {
CRM_Core_Error::debug_log_message("Ignoring exception thrown by nullHandler: {$obj->code}, {$obj->message}");
CRM_Core_Error::debug_log_message("Ignoring exception thrown by nullHandler: {$obj->code}, {$obj->message}", FALSE, '', PEAR_LOG_ERR);
CRM_Core_Error::backtrace('backTrace', TRUE);
return $obj;
}

0 comments on commit 2b3a163

Please sign in to comment.