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{}
Хуков нет.
Возвращает
true|false. 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 10.5.0
public function write_to_file( string $source, string $text, ?int $time = null ): bool {
if ( is_null( $time ) ) {
$time = time();
}
$file_id = File::generate_file_id( $source, null, $time );
$file = $this->get_file_by_id( $file_id );
if ( $file instanceof File && $file->get_file_size() >= $this->get_file_size_limit() ) {
$rotated = $this->rotate_file( $file->get_file_id() );
if ( $rotated ) {
$file = null;
} else {
return false;
}
}
if ( ! $file instanceof File ) {
$new_path = Settings::get_log_directory() . $this->generate_filename( $source, $time );
$file = new File( $new_path );
}
return $file->write( $text );
}