예제 #1
0
 /**
  * Enables displaying or logging errors and exceptions.
  * @param  mixed         production, development mode, autodetection or IP address(es) whitelist.
  * @param  string        error log directory; enables logging in production mode, FALSE means that logging is disabled
  * @param  string        administrator email; enables email sending in production mode
  * @return void
  */
 public static function enable($mode = NULL, $logDirectory = NULL, $email = NULL)
 {
     parent::enable($mode, $logDirectory, $email);
     self::$blueScreen = self::getBlueScreen();
     self::$bar = self::getBar();
     self::$logger = self::getLogger();
     self::$fireLogger = self::getFireLogger();
     self::$consoleColors =& Tracy\Dumper::$terminalColors;
 }
예제 #2
0
 /**
  * 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) . '&nbsp; <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]) . '&nbsp; <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()
 }
예제 #3
0
 /**
  * @return FireLogger
  */
 public static function getFireLogger()
 {
     if (!self::$fireLogger) {
         self::$fireLogger = new FireLogger();
     }
     return self::$fireLogger;
 }
예제 #4
0
 /**
  * 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) . '&nbsp; <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()
 }