Automattic\WooCommerce\Internal\Admin\Logging\FileV2
FileController::write_to_file
Write a log entry to the appropriate file, after rotating the file if necessary.
Метод класса: FileController{}
Хуков нет.
Возвращает
bool. True if the contents were successfully written to the file.
Использование
$FileController = new FileController(); $FileController->write_to_file( $source, $text, ?int $time ): bool;
- $source(строка) (обязательный)
- The source property of the log entry, which determines which file to write to.
- $text(строка) (обязательный)
- The contents of the log entry to add to a file.
- ?int $time
- .
По умолчанию:null
Код FileController::write_to_file() FileController::write to file WC 11.2.2
public function write_to_file( string $source, string $text, ?int $time = null ): bool {
if ( is_null( $time ) ) {
$time = time();
}
$path = Settings::get_log_directory() . $this->generate_filename( $source, $time );
$file = new File( $path );
$size = $file->get_file_size();
if ( false !== $size && $size >= $this->get_file_size_limit() ) {
if ( ! $this->rotate_file( $file ) ) {
return false;
}
$file = new File( $path );
}
return $file->write( $text );
}