ZF-6972: Writer_Firebug calculates wrong occurence of "log" in stack trace

Issue Type: Bug Created: 2009-06-10T00:16:04.000+0000 Last Updated: 2012-11-20T21:37:49.000+0000 Status: Open Fix version(s): Reporter: Sebastian Krebs (kingcrunch) Assignee: None Tags: - Zend_Log

Related issues: Attachments: - ZF-6972.patch


In Writer_Firebug::_write() the traceOffset is hardcoded at line 185. The leads to the problem, that in some cases it calculated the wrong file and line, in which the log should occur.

Somewhere in a function or class-method

<pre class="highlight">// Simple file
$log = new Zend_Log(new Zend_Log_Writer_Firebug();
function test($log) {
  $log->log('test', 6);
test ($log);

The first one works correctly, it gives the correct file and line. The second one (in this case) sends no file and line, in this and all other cases it goes one step "too far".

The hardcoded value expects, that the log is called via __call() in every case, but if I call log() directly there is one stack-entry to less, or if I overwrite Zend_Log::log() or Zend_Log::__call() (or both), the stack trace is "too big" and will return some file/line from some of the log-classes.

I hope, you understand ...

Version is 15892


Posted by Christopher Thomas (cwt137) on 2010-01-18T08:30:04.000+0000

Attached is a patch

Posted by Francois (frankyz) on 2010-06-26T01:10:44.000+0000

The Problem ist the hardcoded traceOffset in Zend_Log_Writer_Firebug. But this Patch is not the right solution.

My function:

<pre class="highlight">
function debug()
    if (func_num_args() == 1)
    else if (func_num_args() > 1)

In this case, the traceOffset is 7, not the hardcoded 6 or the count of debug_backtrace() - in my special example 18).

The best solution, is to set the TraceOffset by defult of 6:

<pre class="highlight">
Zend_Wildfire_Plugin_FirePhp::getInstance()->setOption('traceOffset' , 6);

Don't set hardcoded the traceOffset:

<pre class="highlight">

Now, i can change the Offset outside from the Writer, with ```

Note: this solution is not the right one, if concurrent usage on Zend_Wildfire_Plugin_FirePhp. If this a risk, so the Writer must implemend set/get FirebugOption Methods...

Posted by Francois (frankyz) on 2010-06-26T01:22:59.000+0000

;) The better solution is to use the $event array.

<pre class="highlight">
$traceOffset = isset($event['traceOffset'])?$event['traceOffset']:6;

Example on my function:

<pre class="highlight">
function debug()
    if (func_num_args() == 1)
       Zend_Registry::get('log')->debug(func_get_arg(0), array('traceOffset' => 7));
       Zend_Registry::get('log')->debug(func_get_args(), array('traceOffset' => 7));

So everyone can set the right traceOffset...

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.