[ 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 instantiated within class Database\YDB
  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      yourls_get_db('read-debug_log')->getProfiler()->getLogger()->log('debug', $msg);
  19      return $msg;
  20  }
  21  
  22  /**
  23   * Get the debug log
  24   *
  25   * @since  1.7.3
  26   * @return array
  27   */
  28  function yourls_get_debug_log() {
  29      return yourls_get_db('read-get_debug_log')->getProfiler()->getLogger()->getMessages();
  30  }
  31  
  32  /**
  33   * Get number of SQL queries performed
  34   *
  35   * @return int
  36   */
  37  function yourls_get_num_queries() {
  38      return yourls_apply_filter( 'get_num_queries', yourls_get_db('read-get_num_queries')->get_num_queries() );
  39  }
  40  
  41  /**
  42   * Debug mode set
  43   *
  44   * @since 1.7.3
  45   * @param bool $bool Debug on or off
  46   * @return void
  47   */
  48  function yourls_debug_mode( $bool ) {
  49      // log queries if true
  50      yourls_get_db('read-debug_mode')->getProfiler()->setActive( (bool)$bool );
  51  
  52      // report notices if true
  53      $level = $bool ? -1 : ( E_ERROR | E_PARSE );
  54      error_reporting( $level );
  55  }
  56  
  57  /**
  58   * Return YOURLS debug mode
  59   *
  60   * @since 1.7.7
  61   * @return bool
  62   */
  63  function yourls_get_debug_mode() {
  64      return defined( 'YOURLS_DEBUG' ) && YOURLS_DEBUG;
  65  }


Generated: Tue Jan 27 05:10:15 2026 Cross-referenced by PHPXref 0.7.1