logo       

4080 - in trunk: EventLog EventLog/src/exceptions EventLog/src/writers Even: msg#00250

web.ezcomponents.cvs

Subject: 4080 - in trunk: EventLog EventLog/src/exceptions EventLog/src/writers EventLogDatabaseTiein/tests/writers [eZComponents: Trunk]

Author: Alexandru Stanoi
Date: 2006-11-27 14:09:47 +0100 (Mon, 27 Nov 2006)
New Revision: 4080

Log:
- Fixed bug #9603: The exception message in ezcLogWriterException is now
passed to the parent exception.
- Added a test for it in ezcEventLogDatabaseTieIn.

Modified:
trunk/EventLog/ChangeLog
trunk/EventLog/src/exceptions/writer_exception.php
trunk/EventLog/src/writers/writer_file.php
trunk/EventLogDatabaseTiein/tests/writers/writer_database_test.php

Modified: trunk/EventLog/ChangeLog
===================================================================
--- trunk/EventLog/ChangeLog 2006-11-27 12:57:04 UTC (rev 4079)
+++ trunk/EventLog/ChangeLog 2006-11-27 13:09:47 UTC (rev 4080)
@@ -1,3 +1,10 @@
+1.0.3 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Fixed bug #9603: The exception message in ezcLogWriterException is now
+ passed to the parent exception.
+
+
1.0.2 - Monday 28 August 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Modified: trunk/EventLog/src/exceptions/writer_exception.php
===================================================================
--- trunk/EventLog/src/exceptions/writer_exception.php 2006-11-27 12:57:04 UTC
(rev 4079)
+++ trunk/EventLog/src/exceptions/writer_exception.php 2006-11-27 13:09:47 UTC
(rev 4080)
@@ -17,7 +17,7 @@
* @package EventLog
* @version //autogen//
*/
-class ezcLogWriterException extends Exception
+class ezcLogWriterException extends ezcBaseException
{
public $exception;

@@ -29,6 +29,7 @@
public function __construct( Exception $e )
{
$this->exception = $e;
+ parent::__construct( $e->getMessage() );
}
}
?>

Modified: trunk/EventLog/src/writers/writer_file.php
===================================================================
--- trunk/EventLog/src/writers/writer_file.php 2006-11-27 12:57:04 UTC (rev
4079)
+++ trunk/EventLog/src/writers/writer_file.php 2006-11-27 13:09:47 UTC (rev
4080)
@@ -154,7 +154,7 @@
$failure = false;
foreach ( $fileHandles as $filename => $fh )
{
- if ( fwrite( $fh, $string ) === false)
+ if ( fwrite( $fh, $string ) === false )
{
$failure = $filename;
}
@@ -162,7 +162,7 @@

if ( $failure )
{
- throw ezcLogWriterException( new ezcBaseFileIoException(
$failure, ezcBaseFileIoException::WRITE ) );
+ throw new ezcLogWriterException( new ezcBaseFileIoException(
$failure, ezcBaseFileIoException::WRITE ) );
}

}
@@ -172,7 +172,7 @@
{
if ( fwrite( $this->openFiles[$this->defaultFile], $string )
=== false )
{
- throw ezcLogWriterException( new ezcBaseFileIoException(
$this->defaultFile, ezcBaseFileIoException::WRITE ) );
+ throw new ezcLogWriterException( new
ezcBaseFileIoException( $this->defaultFile, ezcBaseFileIoException::WRITE ) );
}
}
}
@@ -193,17 +193,16 @@
}

clearstatcache();
- if ( file_exists( $this->logDirectory . "/". $fileName ) &&
- ( filesize( $this->logDirectory . "/". $fileName ) >=
$this->maxSize ) )
+ $path = $this->logDirectory . "/". $fileName;
+ if ( file_exists( $path ) &&
+ ( filesize( $path ) >= $this->maxSize ) )
{
$this->rotateLog( $fileName );
}

- $fh = @fopen( $this->logDirectory ."/". $fileName, "a" );
+ $fh = @fopen( $path, "a" );
if ( $fh === false )
{
- $path = $this->logDirectory ."/". $fileName;
-
if ( !file_exists( $path ) )
{
throw new ezcBaseFileNotFoundException( $path, "log" );

Modified: trunk/EventLogDatabaseTiein/tests/writers/writer_database_test.php
===================================================================
--- trunk/EventLogDatabaseTiein/tests/writers/writer_database_test.php
2006-11-27 12:57:04 UTC (rev 4079)
+++ trunk/EventLogDatabaseTiein/tests/writers/writer_database_test.php
2006-11-27 13:09:47 UTC (rev 4080)
@@ -13,7 +13,7 @@
$this->markTestSkipped();
}

- $this->writer = new ezcLogDatabaseWriter( $db, "log");
+ $this->writer = new ezcLogDatabaseWriter( $db, "log" );

$this->assertNotNull( $db, 'Database instance is not initialized.' );

@@ -37,6 +37,23 @@
}


+ public function testWriteNotDefault()
+ {
+ $db = ezcDbInstance::get();
+ $writer = new ezcLogDatabaseWriter( $db, "logtable" );
+ $log = ezcLog::getInstance();
+ $log->getMapper()->appendRule( new ezcLogFilterRule( new ezcLogFilter,
$writer, true ) );
+ try
+ {
+ $log->log( 'Adding category', ezcLog::INFO, array( 'source' =>
'mail' ) );
+ $this->fail( 'Expected exception was not thrown' );
+ }
+ catch ( ezcLogWriterException $e )
+ {
+ $this->assertEquals( "SQLSTATE[42S02]: Base table or view not
found: 1146 Table 'ezc.logtable' doesn't exist", $e->getMessage() );
+ }
+ }
+
public function testWriteDefaultEntries()
{
$this->writer->writeLogMessage("Hello world", ezcLog::WARNING,
"MySource", "MyCategory");



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise