[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/includes/ -> functions-debug.php (source)

   1  <?php
   2  /*
   3   * Functions relative to debugging
   4   */
   5  
   6  /**
   7   * Add a message to the debug log
   8   *
   9   * When in debug mode ( YOURLS_DEBUG == true ) the debug log is echoed in yourls_html_footer()
  10   * Log messages are appended to $ydb->debug_log array, which is instanciated within class ezSQLcore_YOURLS
  11   *
  12   * @since 1.7
  13   * @param string $msg Message to add to the debug log
  14   * @return string The message itself
  15   */
  16  function yourls_debug_log( $msg ) {
  17      yourls_do_action( 'debug_log', $msg );
  18      // Get the DB object ($ydb), get its profiler (\Aura\Sql\Profiler\Profiler), its logger (\Aura\Sql\Profiler\MemoryLogger) and
  19      // pass it a unused argument (loglevel) and the message
  20      yourls_get_db()->getProfiler()->getLogger()->log( 'debug', $msg);
  21      return $msg;
  22  }
  23  
  24  /**
  25   * Get the debug log
  26   *
  27   * @since  1.7.3
  28   * @return array
  29   */
  30  function yourls_get_debug_log() {
  31      return yourls_get_db()->getProfiler()->getLogger()->getMessages();
  32  }
  33  
  34  /**
  35   * Get number of SQL queries performed
  36   *
  37   * @return int
  38   */
  39  function yourls_get_num_queries() {
  40      return yourls_apply_filter( 'get_num_queries', yourls_get_db()->get_num_queries() );
  41  }
  42  
  43  /**
  44   * Debug mode set
  45   *
  46   * @since 1.7.3
  47   * @param bool $bool Debug on or off
  48   * @return void
  49   */
  50  function yourls_debug_mode( $bool ) {
  51      // log queries if true
  52      yourls_get_db()->getProfiler()->setActive( (bool)$bool );
  53  
  54      // report notices if true
  55      $level = $bool ? -1 : ( E_ERROR | E_PARSE );
  56      error_reporting( $level );
  57  }
  58  
  59  /**
  60   * Return YOURLS debug mode
  61   *
  62   * @since 1.7.7
  63   * @return bool
  64   */
  65  function yourls_get_debug_mode() {
  66      return defined( 'YOURLS_DEBUG' ) && YOURLS_DEBUG;
  67  }


Generated: Wed Sep 28 05:10:02 2022 Cross-referenced by PHPXref 0.7.1