[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/debug/ -> debug.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\debug;
  15  
  16  use Symfony\Component\Debug\BufferingLogger;
  17  use Symfony\Component\Debug\DebugClassLoader;
  18  use Symfony\Component\Debug\ExceptionHandler;
  19  
  20  /**
  21   * Registers all the debug tools.
  22  
  23   * @see Symfony\Component\Debug\Debug
  24   */
  25  class debug
  26  {
  27      static private $enabled = false;
  28  
  29      /**
  30       * Enables the debug tools.
  31       *
  32       * This method registers an error handler and an exception handler.
  33       *
  34       * If the Symfony ClassLoader component is available, a special
  35       * class loader is also registered.
  36       *
  37       * @param int  $errorReportingLevel The level of error reporting you want
  38       * @param bool $displayErrors       Whether to display errors (for development) or just log them (for production)
  39       */
  40  	static public function enable($errorReportingLevel = null, $displayErrors = true)
  41      {
  42          if (static::$enabled)
  43          {
  44              return;
  45          }
  46  
  47          static::$enabled = true;
  48  
  49          if ($errorReportingLevel !== null)
  50          {
  51              error_reporting($errorReportingLevel);
  52          }
  53          else
  54          {
  55              error_reporting(-1);
  56          }
  57  
  58          if ('cli' !== php_sapi_name())
  59          {
  60              ini_set('display_errors', 0);
  61              ExceptionHandler::register();
  62          }
  63          else if ($displayErrors && (!ini_get('log_errors') || ini_get('error_log')))
  64          {
  65              // CLI - display errors only if they're not already logged to STDERR
  66              ini_set('display_errors', 1);
  67          }
  68  
  69          if ($displayErrors)
  70          {
  71              error_handler::register(new error_handler(new BufferingLogger()));
  72          }
  73          else
  74          {
  75              error_handler::register()->throwAt(0, true);
  76          }
  77  
  78          DebugClassLoader::enable();
  79      }
  80  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1