Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Utilitie...
File: LoggingUtil.php
<?php
[0] Fix | Delete
declare( strict_types=1 );
[1] Fix | Delete
[2] Fix | Delete
namespace Automattic\WooCommerce\Utilities;
[3] Fix | Delete
[4] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Logging\{ PageController, Settings };
[5] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Logging\FileV2\{ File, FileController };
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* A class of utilities for dealing with logging.
[9] Fix | Delete
*/
[10] Fix | Delete
final class LoggingUtil {
[11] Fix | Delete
/**
[12] Fix | Delete
* Get the canonical URL for the Logs tab of the Status admin page.
[13] Fix | Delete
*
[14] Fix | Delete
* @return string
[15] Fix | Delete
*/
[16] Fix | Delete
public static function get_logs_tab_url(): string {
[17] Fix | Delete
return wc_get_container()->get( PageController::class )->get_logs_tab_url();
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Determine the current value of the logging_enabled setting.
[22] Fix | Delete
*
[23] Fix | Delete
* @return bool
[24] Fix | Delete
*/
[25] Fix | Delete
public static function logging_is_enabled(): bool {
[26] Fix | Delete
return wc_get_container()->get( Settings::class )->logging_is_enabled();
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Determine the current value of the default_handler setting.
[31] Fix | Delete
*
[32] Fix | Delete
* @return string
[33] Fix | Delete
*/
[34] Fix | Delete
public static function get_default_handler(): string {
[35] Fix | Delete
return wc_get_container()->get( Settings::class )->get_default_handler();
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Determine the current value of the retention_period_days setting.
[40] Fix | Delete
*
[41] Fix | Delete
* @return int
[42] Fix | Delete
*/
[43] Fix | Delete
public static function get_retention_period(): int {
[44] Fix | Delete
return wc_get_container()->get( Settings::class )->get_retention_period();
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Determine the current value of the level_threshold setting.
[49] Fix | Delete
*
[50] Fix | Delete
* @return string
[51] Fix | Delete
*/
[52] Fix | Delete
public static function get_level_threshold(): string {
[53] Fix | Delete
return wc_get_container()->get( Settings::class )->get_level_threshold();
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Generate a public ID for a log file based on its properties.
[58] Fix | Delete
*
[59] Fix | Delete
* The file ID is the basename of the file without the hash part. It allows us to identify a file without revealing
[60] Fix | Delete
* its full name in the filesystem, so that it's difficult to access the file directly with an HTTP request.
[61] Fix | Delete
*
[62] Fix | Delete
* @param string $source The source of the log entries contained in the file.
[63] Fix | Delete
* @param int|null $rotation Optional. The 0-based incremental rotation marker, if the file has been rotated.
[64] Fix | Delete
* Should only be a single digit.
[65] Fix | Delete
* @param int $created Optional. The date the file was created, as a Unix timestamp.
[66] Fix | Delete
*
[67] Fix | Delete
* @return string
[68] Fix | Delete
*/
[69] Fix | Delete
public static function generate_log_file_id( string $source, ?int $rotation = null, int $created = 0 ): string {
[70] Fix | Delete
return File::generate_file_id( $source, $rotation, $created );
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Generate a hash to use as the suffix on a log filename.
[75] Fix | Delete
*
[76] Fix | Delete
* @param string $file_id A file ID (file basename without the hash).
[77] Fix | Delete
*
[78] Fix | Delete
* @return string
[79] Fix | Delete
*/
[80] Fix | Delete
public static function generate_log_file_hash( string $file_id ): string {
[81] Fix | Delete
return File::generate_hash( $file_id );
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Get the directory for storing log files.
[86] Fix | Delete
*
[87] Fix | Delete
* @param bool $create_dir Optional. True to attempt to create the log directory if it doesn't exist. Default true.
[88] Fix | Delete
*
[89] Fix | Delete
* @return string The full directory path, with trailing slash.
[90] Fix | Delete
*/
[91] Fix | Delete
public static function get_log_directory( bool $create_dir = true ): string {
[92] Fix | Delete
return Settings::get_log_directory( $create_dir );
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Calculate the size, in bytes, of the log directory.
[97] Fix | Delete
*
[98] Fix | Delete
* @return int
[99] Fix | Delete
*/
[100] Fix | Delete
public static function get_log_directory_size(): int {
[101] Fix | Delete
return wc_get_container()->get( FileController::class )->get_log_directory_size();
[102] Fix | Delete
}
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function