Here's one solution:

<?php
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
class Karwin_Log extends Zend_Log
{
  const DEBUG_BACKTRACE = 8;
  public function debug_backtrace($message = null)
  {
    $backtrace = array_shift(debug_backtrace());
    unset($backtrace['object']);
    $backtrace = print_r($backtrace, true);
    $message = (array) $message;
    array_push($message, $backtrace);
    $message = array(implode(': ', $message));
    $this->__call('DEBUG_BACKTRACE', $message);
  }
}

$log = new Karwin_Log(new Zend_Log_Writer_Stream('php://output'));
$log->debug_backtrace('Something happened');

Regards,
Bill Karwin

> -----Original Message-----
> From: Truppe Steven [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 16, 2007 1:24 PM
> To: [email protected]
> Subject: [fw-general] Troubles trying to understand how to 
> extend Zend_Log
> 
> Hi again,
> 
> i have found debug_backtrace() function in php that returns 
> all information about the current method/function called. So 
> i want to be able to pass the result of debug_backtrace 
> function to my Zend_Log somehow so it gets output in a 
> certain format. So i can just use
> 
>     $log->debug_backtrace();
> 
> in every method/function that should get debugged.
> 
> Now the question is how to best achive this ? Should i just 
> extend Zend/Log/Writer/Abstract.php and add the 
> debug_backtrace() method ? Or is there another way with 
> events or custom formatter ?
> 
> I'm very curious about the answer.
> 
> 
> best regards,
> Steven Truppe
> 

Reply via email to