/** * Static class constructor. * @internal */ public static function _init() { self::$time = microtime(TRUE); self::$consoleMode = PHP_SAPI === 'cli'; self::$productionMode = self::DETECT; if (self::$consoleMode) { self::$source = empty($_SERVER['argv']) ? 'cli' : 'cli: ' . implode(' ', $_SERVER['argv']); } else { self::$ajaxDetected = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'; if (isset($_SERVER['REQUEST_URI'])) { self::$source = (isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://') . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '')) . $_SERVER['REQUEST_URI']; } } self::$logger = new Logger(); self::$logDirectory =& self::$logger->directory; self::$email =& self::$logger->email; self::$mailer =& self::$logger->mailer; self::$emailSnooze =& Logger::$emailSnooze; self::$fireLogger = new FireLogger(); self::$blueScreen = new BlueScreen(); self::$blueScreen->addPanel(function ($e) { if ($e instanceof Nette\Templating\FilterException) { return array('tab' => 'Template', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($e->sourceFile, $e->sourceLine) . ' <b>Line:</b> ' . ($e->sourceLine ? $e->sourceLine : 'n/a') . '</p>' . ($e->sourceLine ? '<pre>' . BlueScreen::highlightFile($e->sourceFile, $e->sourceLine) . '</pre>' : '')); } }); self::$bar = new Bar(); self::$bar->addPanel(new DefaultBarPanel('time')); self::$bar->addPanel(new DefaultBarPanel('memory')); self::$bar->addPanel(self::$errorPanel = new DefaultBarPanel('errors')); // filled by _errorHandler() self::$bar->addPanel(self::$dumpPanel = new DefaultBarPanel('dumps')); // filled by barDump() }
/** * @return BlueScreen */ public static function getBlueScreen() { if (!self::$blueScreen) { self::$blueScreen = new BlueScreen(); self::$blueScreen->collapsePaths[] = dirname(__DIR__); self::$blueScreen->addPanel(function ($e) { if ($e instanceof Nette\Templating\FilterException) { return array('tab' => 'Template', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($e->sourceFile, $e->sourceLine) . '</p>' . ($e->sourceLine ? BlueScreen::highlightFile($e->sourceFile, $e->sourceLine) : '')); } elseif ($e instanceof Nette\Utils\NeonException && preg_match('#line (\\d+)#', $e->getMessage(), $m)) { if ($item = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) { return array('tab' => 'NEON', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($item['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($item['args'][0], $m[1])); } elseif ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Utils\\Neon::decode')) { return array('tab' => 'NEON', 'panel' => BlueScreen::highlightPhp($item['args'][0], $m[1])); } } }); } return self::$blueScreen; }
/** * Static class constructor. * @internal */ public static function _init() { self::$time = isset($_SERVER['REQUEST_TIME_FLOAT']) ? $_SERVER['REQUEST_TIME_FLOAT'] : microtime(TRUE); self::$consoleMode = PHP_SAPI === 'cli'; self::$productionMode = self::DETECT; if (self::$consoleMode) { self::$source = empty($_SERVER['argv']) ? 'cli' : 'cli: ' . implode(' ', $_SERVER['argv']); } else { self::$ajaxDetected = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'; if (isset($_SERVER['REQUEST_URI'])) { self::$source = (isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://') . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '')) . $_SERVER['REQUEST_URI']; } } self::$logger = new Logger(); self::$logDirectory =& self::$logger->directory; self::$email =& self::$logger->email; self::$mailer =& self::$logger->mailer; self::$emailSnooze =& Logger::$emailSnooze; self::$fireLogger = new FireLogger(); self::$blueScreen = new BlueScreen(); self::$blueScreen->addPanel(function ($e) { if ($e instanceof Nette\Templating\FilterException) { return array('tab' => 'Template', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($e->sourceFile, $e->sourceLine) . ' <b>Line:</b> ' . ($e->sourceLine ? $e->sourceLine : 'n/a') . '</p>' . ($e->sourceLine ? BlueScreen::highlightFile($e->sourceFile, $e->sourceLine) : '')); } elseif ($e instanceof Nette\Utils\NeonException && preg_match('#line (\\d+)#', $e->getMessage(), $m)) { if ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Config\\Adapters\\NeonAdapter::load')) { return array('tab' => 'NEON', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($item['args'][0], $m[1]) . ' <b>Line:</b> ' . $m[1] . '</p>' . BlueScreen::highlightFile($item['args'][0], $m[1])); } elseif ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Utils\\Neon::decode')) { return array('tab' => 'NEON', 'panel' => BlueScreen::highlightPhp($item['args'][0], $m[1])); } } }); self::$bar = new Bar(); self::$bar->addPanel(new DefaultBarPanel('time')); self::$bar->addPanel(new DefaultBarPanel('memory')); self::$bar->addPanel(self::$errorPanel = new DefaultBarPanel('errors')); // filled by _errorHandler() self::$bar->addPanel(self::$dumpPanel = new DefaultBarPanel('dumps')); // filled by barDump() }