You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by "David Pattison (JIRA)" <ji...@apache.org> on 2010/10/14 21:15:32 UTC

[jira] Updated: (LOG4PHP-127) PHP Fatal error: Nesting level too deep - recursive dependency? when logging an object with recursive dependancies

     [ https://issues.apache.org/jira/browse/LOG4PHP-127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Pattison updated LOG4PHP-127:
-----------------------------------


Here is a patch:

Index: renderers/LoggerRendererDefault.php
===================================================================
--- renderers/LoggerRendererDefault.php	(revision 26200)
+++ renderers/LoggerRendererDefault.php	(revision 26226)
@@ -46,6 +46,7 @@
 	 * @return string
 	 */
 	public function render($o) {
-		return var_export($o, true);
+		//using print_r instead of var_export because it recurses nicely
+		return print_r($o, true);
 	}
 }


> PHP Fatal error: Nesting level too deep - recursive dependency? when logging an object with recursive dependancies
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4PHP-127
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-127
>             Project: Log4php
>          Issue Type: Bug
>          Components: Code
>    Affects Versions: 2.0
>         Environment: linux ubuntu 8.04
> php 5.2
> Log4php 2.0.0
>            Reporter: David Pattison
>
> I ran into a problem when you try to log an object with a circular dependency, such as $GLOBALS
> here is a phpsh example:
> php> require 'Logger.php';
> php> Logger::getLogger('foo')->debug($GLOBALS);
> array (
>   'GLOBALS' => 
>   array (
>     'GLOBALS' => 
>     array (
>       'GLOBALS' => 
>       array (
> Fatal error: Nesting level too deep - recursive dependency? in /Users/davidp/Documents/workspace/zoosk-trunk-features/tools/include/vendor/log4php/renderers/LoggerRendererDefault.php on line 49
> I am planing to patch my system so it uses print_r() which will not die in theses cases.
> When I do that I would get this output:
> php> require 'Logger.php';Logger::getLogger('foo')->debug($GLOBALS);
> Thu Oct 14 18:58:48 2010,051 [2688] DEBUG foo - Array
> (
>     [GLOBALS] => Array
>  *RECURSION*
>     [_ENV] => Array
>         (
>             [TERM_PROGRAM] => Apple_Terminal
>             [SHELL] => /bin/bash
>             [TERM] => xterm-color
>             [TMPDIR] => /var/folders/ME/ME4jssgwHQKMN3vofuUXEU++03M/-Tmp-/
>             [Apple_PubSub_Socket_Render] => /tmp/launch-pRh4q5/Render
>             [TERM_PROGRAM_VERSION] => 273
> ... ommited...
> some links about theses two methods:
> http://www.php.net/manual/en/function.var-export.php
> http://www.php.net/manual/en/function.print-r.php
> Thanks,
> Dave

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.