For more information, see www.phpernote.comphp-function929.html. It mainly deals with the problem of writing log files to the disk with a certain amount of concurrency. In fact, fopen or fclose may occasionally fail, but no exception is handled here .? Php *** CreatedbyPhpS
For more information, see http://www.phpernote.com/php-function/929.html. It mainly deals with the problem of writing log files to the disk with a certain amount of concurrency. In fact, fopen or fclose may occasionally fail, but no exception is handled here. ? Php/*** Created by PhpS
For more information, see http://www.phpernote.com/php-function/929.html.
It mainly deals with the problem of writing log files to the disk with a certain amount of concurrency.
In fact, fopen or fclose may occasionally fail, but no exception is handled here.
= $ Max_size) {$ new_log_file = '/logs/error _'. date ('ymdhis '). '. log'; rename ($ log_file, $ new_log_file) ;}}$ fp = fopen ($ log_file, 'a + '); if ($ fp) {$ startTime = microtime (); do {// This loop ensures that the process fails to lock the file after 1 m of attempts, then, discard the log Writing Operation $ canWrite = flock ($ fp, LOCK_EX); if (! $ CanWrite) {usleep (round (rand (0,100) * 1000) ;}} while ((! $ CanWrite) & (microtime ()-$ startTime) <1000); if ($ canWrite) {$ content = date ('Y-m-d H: I: s '). ''. $ log_content. "\ r \ n"; fwrite ($ fp, $ content) ;}fclose ($ fp );}}