Issues

ZF-12435: Passing an exception as the message to Zend_Log_Writer_Db raises an exception

Issue Type:

Bug

Created:

2012-10-04T16:35:39.000+0000

Last Updated:

2013-04-05T16:07:14.000+0000

Status:

Closed

Fix version(s):

Reporter:

Andrew Ballard (aballard)

Assignee:

Frank Brückner (frosch)

Tags:

Zend_Log

Related issues:

Attachments:

Description

The other log writers allow you to pass an instance of an exception as the message for logging. In particular, Zend_Log_Writer_Firebug even has a formatter that renders in a way that is easy to read when debugging XmlHttpRequests. However, I get an exception in Zend_Log_Writer_Db because the message is an object:

18 ..\public\index.php(126): Zend_Application->run()

19 {main}

{panel}

I can pass the exception in as a string, but then it is more difficult to read in Firebug. I'm also not sure if this problem is specific to the database adapter I am using (Zend_Db_Adapter_Sqlsrv) since I don't have another database/adapter I can test right now.

I think a change in Zend_Log_Writer_Db::_write() should fix it but I don't know if it might raise other issues:

I tried to resolve this by extending Zend_Log_Writer_Db to override the _write method, but all of the properties are marked private instead of protected for some reason. As a result, getting it to work would have required duplicating the entire class. (If they truly need to be private, perhaps the class should be final?)

Comments

Posted by Andrew Ballard (aballard) on 2012-10-04T16:54:23.000+0000

Fixed code block.

Posted by Frank Brückner (frosch) on 2013-02-15T07:01:44.000+0000

Hi Andrew,
I will look into your problem with exceptions. I must write a unit test.

{quote} tried to resolve this by extending Zend_Log_Writer_Db to override the _write method, but all of the properties are marked private instead of protected for some reason.{quote}
This problem was fixed with ZF-12514. (Look at the diff)

Thanks for your help! :)

Posted by Andrew Ballard (aballard) on 2013-02-15T17:40:24.000+0000

{quote}
bq. tried to resolve this by extending Zend_Log_Writer_Db to override the _write method, but all of the properties are marked private instead of protected for some reason.

This problem was fixed with ZF-12514.{quote}

Thank you!

I was ultimately able to extend {{Zend_Log_Writer_Db}} in a way that works with the current version. I'm still not sure if this is the best way of handling things, but this is the class I came up with: