Automattic\WooCommerce\Internal\Admin\Logging\FileV2
FileController::get_file_sources
Get a list of sources for existing log files.
Method of the class: FileController{}
No Hooks.
Returns
Array|WP_Error.
Usage
$FileController = new FileController(); $FileController->get_file_sources();
FileController::get_file_sources() FileController::get file sources code WC 10.3.3
public function get_file_sources() {
$paths = glob( Settings::get_log_directory() . '*.log' );
if ( false === $paths ) {
return new WP_Error(
'wc_log_directory_error',
__( 'Could not access the log file directory.', 'woocommerce' )
);
}
$all_sources = array_map(
function( $path ) {
$file = new File( $path );
return $file->is_readable() ? $file->get_source() : null;
},
$paths
);
return array_unique( array_filter( $all_sources ) );
}