Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/core/componen...
File: Logger.php
<?php
[0] Fix | Delete
[1] Fix | Delete
[2] Fix | Delete
class ET_Core_Logger {
[3] Fix | Delete
[4] Fix | Delete
/**
[5] Fix | Delete
* @var ET_Core_Data_Utils
[6] Fix | Delete
*/
[7] Fix | Delete
protected static $_;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Checksum for every log message output during the current request.
[11] Fix | Delete
*
[12] Fix | Delete
* @var string[]
[13] Fix | Delete
*/
[14] Fix | Delete
protected static $HISTORY = array();
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Writes a message to the debug log if it hasn't already been written once.
[18] Fix | Delete
*
[19] Fix | Delete
* @since 3.10
[20] Fix | Delete
*
[21] Fix | Delete
* @param mixed $message
[22] Fix | Delete
* @param int $bt_index
[23] Fix | Delete
* @param boolean $log_ajax Whether or not to log on AJAX calls.
[24] Fix | Delete
*/
[25] Fix | Delete
protected static function _maybe_write_log( $message, $bt_index = 4, $log_ajax = true ) {
[26] Fix | Delete
global $ET_IS_TESTING_DEPRECATIONS;
[27] Fix | Delete
[28] Fix | Delete
if ( ! is_scalar( $message ) ) {
[29] Fix | Delete
$message = print_r( $message, true );
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
$message = (string) $message;
[33] Fix | Delete
$hash = md5( $message );
[34] Fix | Delete
[35] Fix | Delete
if ( ! $log_ajax && wp_doing_ajax() ) {
[36] Fix | Delete
return;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
if ( $ET_IS_TESTING_DEPRECATIONS ) {
[40] Fix | Delete
trigger_error( $message );
[41] Fix | Delete
[42] Fix | Delete
} else if ( getenv( 'CI' ) || ! in_array( $hash, self::$HISTORY ) ) {
[43] Fix | Delete
self::$HISTORY[] = $hash;
[44] Fix | Delete
[45] Fix | Delete
self::_write_log( $message, $bt_index );
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Writes a message to the WP Debug and PHP Error logs.
[51] Fix | Delete
*
[52] Fix | Delete
* @param string $message
[53] Fix | Delete
* @param int $bt_index
[54] Fix | Delete
*/
[55] Fix | Delete
private static function _write_log( $message, $bt_index = 4 ) {
[56] Fix | Delete
$message = trim( $message );
[57] Fix | Delete
$backtrace = debug_backtrace( 1 );
[58] Fix | Delete
$class = '';
[59] Fix | Delete
$function = '';
[60] Fix | Delete
[61] Fix | Delete
if ( ! isset( $backtrace[ $bt_index ] ) ) {
[62] Fix | Delete
while ( $bt_index > 0 && ! isset( $backtrace[ $bt_index ] ) ) {
[63] Fix | Delete
$bt_index--;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
// We need two stacks to get all the data we need so let's go down one more
[67] Fix | Delete
$bt_index--;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
$stack = $backtrace[ $bt_index ];
[71] Fix | Delete
$file = self::$_->array_get( $stack, 'file', '<unknown file>' );
[72] Fix | Delete
$line = self::$_->array_get( $stack, 'line', '<unknown line>' );
[73] Fix | Delete
[74] Fix | Delete
// Name of the function and class (if applicable) are in the previous stack (stacks are in reverse order)
[75] Fix | Delete
$stack = $backtrace[ $bt_index + 1 ];
[76] Fix | Delete
$class = self::$_->array_get( $stack, 'class', '' );
[77] Fix | Delete
$function = self::$_->array_get( $stack, 'function', '<unknown function>' );
[78] Fix | Delete
[79] Fix | Delete
if ( $class ) {
[80] Fix | Delete
$class .= '::';
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
if ( '<unknown file>' !== $file ) {
[84] Fix | Delete
$file = _et_core_normalize_path( $file );
[85] Fix | Delete
$parts = explode( '/', $file );
[86] Fix | Delete
$parts = array_slice( $parts, -2 );
[87] Fix | Delete
$file = ".../{$parts[0]}/{$parts[1]}";
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
$message = " {$file}:{$line} {$class}{$function}():\n{$message}\n";
[91] Fix | Delete
[92] Fix | Delete
error_log( $message );
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Writes message to the logs if {@link WP_DEBUG} is `true`, otherwise does nothing.
[97] Fix | Delete
*
[98] Fix | Delete
* @since 1.1.0
[99] Fix | Delete
*
[100] Fix | Delete
* @param mixed $message
[101] Fix | Delete
* @param int $bt_index
[102] Fix | Delete
* @param boolean $log_ajax Whether or not to log on AJAX calls.
[103] Fix | Delete
*/
[104] Fix | Delete
public static function debug( $message, $bt_index = 4, $log_ajax = true ) {
[105] Fix | Delete
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
[106] Fix | Delete
self::_maybe_write_log( $message, $bt_index, $log_ajax );
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
public static function disable_php_notices() {
[111] Fix | Delete
$error_reporting = error_reporting();
[112] Fix | Delete
$notices_enabled = $error_reporting & E_NOTICE;
[113] Fix | Delete
[114] Fix | Delete
if ( $notices_enabled ) {
[115] Fix | Delete
error_reporting( $error_reporting & ~E_NOTICE );
[116] Fix | Delete
}
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Writes an error message to the logs regardless of whether or not debug mode is enabled.
[121] Fix | Delete
*
[122] Fix | Delete
* @since 1.1.0
[123] Fix | Delete
*
[124] Fix | Delete
* @param mixed $message
[125] Fix | Delete
* @param int $bt_index
[126] Fix | Delete
*/
[127] Fix | Delete
public static function error( $message, $bt_index = 4 ) {
[128] Fix | Delete
self::_maybe_write_log( $message, $bt_index );
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
public static function enable_php_notices() {
[132] Fix | Delete
$error_reporting = error_reporting();
[133] Fix | Delete
$notices_enabled = $error_reporting & E_NOTICE;
[134] Fix | Delete
[135] Fix | Delete
if ( ! $notices_enabled ) {
[136] Fix | Delete
error_reporting( $error_reporting | E_NOTICE );
[137] Fix | Delete
}
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
public static function initialize() {
[141] Fix | Delete
self::$_ = ET_Core_Data_Utils::instance();
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
public static function php_notices_enabled() {
[145] Fix | Delete
$error_reporting = error_reporting();
[146] Fix | Delete
return $error_reporting & E_NOTICE;
[147] Fix | Delete
}
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
[151] Fix | Delete
ET_Core_Logger::initialize();
[152] Fix | Delete
[153] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function