Navigation Menu

Skip to content

Commit

Permalink
WIP: Debugger: store debug bars in ajax requests
Browse files Browse the repository at this point in the history
They can be retrieved by a subsequent request
  • Loading branch information
juzna committed Oct 6, 2012
1 parent 1bf2842 commit 079a566
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Nette/Diagnostics/Bar.php
Expand Up @@ -109,4 +109,13 @@ public function render()
require __DIR__ . '/templates/bar.phtml';
}



public function __toString()
{
ob_start();
$this->render();
return ob_get_clean();
}

}
25 changes: 22 additions & 3 deletions Nette/Diagnostics/Debugger.php
Expand Up @@ -117,6 +117,9 @@ final class Debugger
/** @deprecated */
public static $emailSnooze;

/** @var string */
public static $intermediateDebugFile;

/********************* debug bar ****************d*g**/

/** @var Bar */
Expand Down Expand Up @@ -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')) {
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 079a566

Please sign in to comment.