logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject svn commit: r1394975 - in /logging/log4php/trunk/src: changes/changes.xml main/php/appenders/LoggerAppenderRollingFile.php
Date Sat, 06 Oct 2012 09:33:37 GMT
Author: ihabunek
Date: Sat Oct  6 09:33:36 2012
New Revision: 1394975

URL: http://svn.apache.org/viewvc?rev=1394975&view=rev
Log:
LOG4PHP-186: LoggerAppenderRollingFile: Don't clear the entire stat cache on an append if
possible.

Modified:
    logging/log4php/trunk/src/changes/changes.xml
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php

Modified: logging/log4php/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/changes/changes.xml?rev=1394975&r1=1394974&r2=1394975&view=diff
==============================================================================
--- logging/log4php/trunk/src/changes/changes.xml (original)
+++ logging/log4php/trunk/src/changes/changes.xml Sat Oct  6 09:33:36 2012
@@ -21,6 +21,7 @@
 	</properties>
 	<body>
 		<release version="2.3.0" date="SVN">
+			<action date="2012-10-06" type="update" issue="LOG4PHP-186" dev="Ivan Habunek" due-to="Rasmus
Lerdorf" due-to-email="rasmus at lerdorf dot com">Don't clear the entire stat cache on
an append.</action>
 			<action date="2012-10-06" type="add" issue="LOG4PHP-141" dev="Ivan Habunek">Allow
setting of a default renderer.</action>
 			<action date="2012-09-08" type="update" issue="LOG4PHP-120" dev="Ivan Habunek" due-to="Michal
Vanek" due-to-email="michal dot vanek at gmail dot com">Fixed LoggerAppenderDailyFile to
rollover on date change in long running scipts.</action>
 			<action date="2012-05-29" type="update" dev="Ivan Habunek">Removed $_ENV and $_SERVER
access from LoggerMDC.</action>

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php?rev=1394975&r1=1394974&r2=1394975&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php Sat Oct  6
09:33:36 2012
@@ -80,6 +80,14 @@ class LoggerAppenderRollingFile extends 
 	protected $compress = false;
 
 	/**
+	 * Set to true in the constructor if PHP >= 5.3.0. In that case clearstatcache
+	 * supports conditional clearing of statistics.
+	 * @var boolean
+	 * @see http://php.net/manual/en/function.clearstatcache.php
+	 */
+	private $clearConditional = false;
+	
+	/**
 	 * Get the maximum size that the output file is allowed to reach
 	 * before being rolled over to backup files.
 	 * @return integer
@@ -88,6 +96,13 @@ class LoggerAppenderRollingFile extends 
 		return $this->maxFileSize;
 	}
 
+	public function __construct($name = '') {
+		parent::__construct($name);
+		if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
+			$this->clearConditional = true;
+		}
+	}
+	
 	/**
 	 * Implements the usual roll over behaviour.
 	 *
@@ -197,7 +212,12 @@ class LoggerAppenderRollingFile extends 
 			}
 			
 			// Stats cache must be cleared, otherwise filesize() returns cached results
-			clearstatcache();
+			// If supported (PHP 5.3+), clear only the state cache for the target file
+			if ($this->clearConditional) {
+				clearstatcache(true, $this->file);
+			} else {
+				clearstatcache();
+			}
 			
 			// Rollover if needed
 			if (filesize($this->file) > $this->maxFileSize) {



Mime
View raw message