Print php.log stack traces in reverse order (a more standard order)
authorStephen Soltesz <soltesz@cs.princeton.edu>
Thu, 12 May 2011 21:52:28 +0000 (17:52 -0400)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Thu, 12 May 2011 21:52:28 +0000 (17:52 -0400)
php/plc_api.php

index 3224601..41f65c2 100644 (file)
@@ -61,9 +61,13 @@ class PLCAPI
   function backtrace_php () {
     $backtrace = debug_backtrace();
     $msg = "";
-    foreach( $backtrace as $line ) {
+    $len = count($backtrace);
+    $cnt = 1;
+    foreach( array_reverse($backtrace) as $line ) {
         $msg .= "File '". $line['file'] . "' line " . $line['line'] . "\n";
         $msg .= "    " . $line['function'] . "( "  . $this->rec_join($line['args']) . ")\n";
+        $cnt += 1;
+        if ( $cnt == $len ) { break; }
     }
     return $msg;
   }