Merged in feature/280-dev-dev01 (pull request #21)
auto-patch 280-dev-dev01-2024-01-19T16_41_58 * auto-patch 280-dev-dev01-2024-01-19T16_41_58
This commit is contained in:
@@ -25,7 +25,7 @@ abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
|
||||
* @return string Formatted time for use in log entry.
|
||||
*/
|
||||
protected static function format_time( $timestamp ) {
|
||||
return date( 'c', $timestamp );
|
||||
return gmdate( 'c', $timestamp );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +43,14 @@ abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
|
||||
$level_string = strtoupper( $level );
|
||||
$entry = "{$time_string} {$level_string} {$message}";
|
||||
|
||||
/**
|
||||
* Filter the formatted log entry before it is written.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $entry The formatted entry.
|
||||
* @param array $args The raw data that gets assembled into a log entry.
|
||||
*/
|
||||
return apply_filters(
|
||||
'woocommerce_format_log_entry',
|
||||
$entry,
|
||||
@@ -54,4 +62,37 @@ abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a backtrace that shows where the logging function was called.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function get_backtrace() {
|
||||
// Get the filenames of the logging-related classes so we can ignore them.
|
||||
$ignore_files = array_map(
|
||||
function( $class ) {
|
||||
try {
|
||||
$reflector = new \ReflectionClass( $class );
|
||||
return $reflector->getFileName();
|
||||
} catch ( Exception $exception ) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
array( wc_get_logger(), self::class, static::class )
|
||||
);
|
||||
|
||||
$backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
|
||||
|
||||
$filtered_backtrace = array_filter(
|
||||
$backtrace,
|
||||
function( $frame ) use ( $ignore_files ) {
|
||||
$ignore = isset( $frame['file'] ) && in_array( $frame['file'], $ignore_files, true );
|
||||
|
||||
return ! $ignore;
|
||||
}
|
||||
);
|
||||
|
||||
return array_values( $filtered_backtrace );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user