Permalink
Browse files

WIP: Debugger: store debug bars in ajax requests

They can be retrieved by a subsequent request
  • Loading branch information...
1 parent 1bf2842 commit 079a566f690e518ec1332a8af451124bfdf52131 @juzna committed Oct 6, 2012
Showing with 31 additions and 3 deletions.
  1. +9 −0 Nette/Diagnostics/Bar.php
  2. +22 −3 Nette/Diagnostics/Debugger.php
@@ -109,4 +109,13 @@ public function render()
require __DIR__ . '/templates/bar.phtml';
}
+
+
+ public function __toString()
+ {
+ ob_start();
+ $this->render();
+ return ob_get_clean();
+ }
+
}
@@ -117,6 +117,9 @@
/** @deprecated */
public static $emailSnooze;
+ /** @var string */
+ public static $intermediateDebugFile;
+
/********************* debug bar ****************d*g**/
/** @var Bar */
@@ -254,6 +257,16 @@ public static function enable($mode = NULL, $logDirectory = NULL, $email = NULL)
if (self::$logDirectory) {
ini_set('error_log', self::$logDirectory . '/php_error.log');
}
+ if (isset($_SERVER['HTTP_NETTE_DEBUG_HELPER'])) {
+ $dir = TEMP_DIR . '/_Nette.DebugHelper';
+ if (!file_exists($dir)) {
+ mkdir($dir);
+ }
+ self::$intermediateDebugFile = tempnam($dir, $_SERVER['HTTP_NETTE_DEBUG_HELPER']);
+ if (!headers_sent()) {
+ header("Nette-Debug-Nonce: " . basename(self::$intermediateDebugFile));
+ }
+ }
// php configuration
if (function_exists('ini_set')) {
@@ -374,9 +387,15 @@ public static function _shutdownHandler()
self::_exceptionHandler(new Nette\FatalErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'], NULL, NULL, isset($error['trace']) ? $error['trace'] : NULL));
}
- // debug bar (require HTML & development mode)
- if (!connection_aborted() && self::$bar && !self::$productionMode && self::isHtmlMode()) {
- self::$bar->render();
+ // debug bar (requires development mode)
+ if (!connection_aborted() && self::$bar && !self::$productionMode) {
+ if(self::isHtmlMode()) {
+ self::$bar->render();
+
+ } elseif (self::$intermediateDebugFile) {
+ file_put_contents(self::$intermediateDebugFile, self::$bar->__toString());
+ @chmod(self::$intermediateDebugFile, 0666);
+ }
}
}

0 comments on commit 079a566

Please sign in to comment.