cvs: pear /Log package.php /Log/Log file.php

From: Date: Sun, 10 Apr 2005 22:03:05 +0000
Subject: cvs: pear /Log package.php /Log/Log file.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-31088@lists.php.net to get a copy of this message
jon Sun Apr 10 18:03:05 2005 EDT Modified files: /pear/Log package.php /pear/Log/Log file.php Log: The file handler will now perform advsitory file locking (using flock()) if the 'locking' configuration parameter is set. Bug: 4064 http://cvs.php.net/diff.php/pear/Log/package.php?r1=1.26&r2=1.27&ty=u Index: pear/Log/package.php diff -u pear/Log/package.php:1.26 pear/Log/package.php:1.27 --- pear/Log/package.php:1.26 Sun Apr 10 17:44:18 2005 +++ pear/Log/package.php Sun Apr 10 18:03:04 2005 @@ -6,11 +6,13 @@ $notes = <<<EOT Added stringToPriority() for converting priority names to PEAR_LOG_* constants. The mail mail handler now uses \\r\\n instead of \\n to terminate lines. +The file handler will now perform file locking if the 'locking' parameter is set. EOT; $changelog = <<<EOT Added stringToPriority() for converting priority names to PEAR_LOG_* constants. (Bug 2853) The mail mail handler now uses \\r\\n instead of \\n to terminate lines, per RFC 821. (Bug 4107) +The file handler will now perform advsitory file locking (using flock()) if the 'locking' configuration parameter is set. (Bug 4064) EOT; $package = new PEAR_PackageFileManager(); http://cvs.php.net/diff.php/pear/Log/Log/file.php?r1=1.38&r2=1.39&ty=u Index: pear/Log/Log/file.php diff -u pear/Log/Log/file.php:1.38 pear/Log/Log/file.php:1.39 --- pear/Log/Log/file.php:1.38 Sat Feb 26 09:48:58 2005 +++ pear/Log/Log/file.php Sun Apr 10 18:03:05 2005 @@ -1,8 +1,8 @@ <?php /** - * $Header: /repository/pear/Log/Log/file.php,v 1.38 2005/02/26 14:48:58 chagenbu Exp $ + * $Header: /repository/pear/Log/Log/file.php,v 1.39 2005/04/10 22:03:05 jon Exp $ * - * @version $Revision: 1.38 $ + * @version $Revision: 1.39 $ * @package Log */ @@ -42,6 +42,13 @@ var $_append = true; /** + * Should advisory file locking (i.e., flock()) be used? + * @var boolean + * @access private + */ + var $_locking = false; + + /** * Integer (in octal) containing the log file's permissions mode. * @var integer * @access private @@ -104,6 +111,10 @@ $this->_append = $conf['append']; } + if (isset($conf['locking'])) { + $this->_locking = $conf['locking']; + } + if (!empty($conf['mode'])) { $this->_mode = $conf['mode']; } @@ -273,9 +284,19 @@ $this->_ident, $this->priorityToString($priority), $message) . $this->_eol; + /* If locking is enabled, acquire an exclusive lock on the file. */ + if ($this->_locking) { + flock($this->_fp, LOCK_EX); + } + /* Write the log line to the log file. */ $success = (fwrite($this->_fp, $line) !== false); + /* Unlock the file now that we're finished writing to it. */ + if ($this->_locking) { + flock($this->_fp, LOCK_UN); + } + /* Notify observers about this log message. */ $this->_announce(array('priority' => $priority, 'message' => $message));

« previous php.pear.cvs (#31088) next »