Automattic\WooCommerce\Internal\Logging
RemoteLogger::sanitize_trace
Sanitize the error trace to exclude sensitive data.
Method of the class: RemoteLogger{}
No Hooks.
Returns
String. The sanitized trace.
Usage
// private - for code of main (parent) class only $result = $this->sanitize_trace( $trace ): string;
- $trace(array|string) (required)
- The error trace.
RemoteLogger::sanitize_trace() RemoteLogger::sanitize trace code WC 10.3.6
private function sanitize_trace( $trace ): string {
if ( is_string( $trace ) ) {
return $this->sanitize( $trace );
}
if ( ! is_array( $trace ) ) {
return '';
}
$sanitized_trace = array_map(
function ( $trace_item ) {
if ( is_array( $trace_item ) && isset( $trace_item['file'] ) ) {
$trace_item['file'] = $this->sanitize( $trace_item['file'] );
return $trace_item;
}
return $this->sanitize( $trace_item );
},
$trace
);
$is_array_by_file = isset( $sanitized_trace[0]['file'] );
if ( $is_array_by_file ) {
return SafeGlobalFunctionProxy::wc_print_r( $sanitized_trace, true );
}
return implode( "\n", $sanitized_trace );
}