[moodle] / moodle / lib / weblib.php Repository:

Diff of /moodle/lib/weblib.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1345, Fri Oct 30 14:20:59 2009 WST revision 1.1346, Sun Nov 1 06:02:06 2009 WST

By skodak:

MDL-20693 new NO_DEBUG_DISPLAY define

# Line 3140  Line 3140 
3140   * trigger_error() or error_log(). Using echo or print will break XHTML   * trigger_error() or error_log(). Using echo or print will break XHTML
3141   * JS and HTTP headers.   * JS and HTTP headers.
3142   *   *
3143     * It is also possible to define NO_DEBUG_DISPLAY which redirects the message to error_log.
3144   *   *
  * @global object  
3145   * @uses DEBUG_NORMAL   * @uses DEBUG_NORMAL
3146   * @param string $message a message to print   * @param string $message a message to print
3147   * @param int $level the level at which this debugging statement should show   * @param int $level the level at which this debugging statement should show
# Line 3164  Line 3164 
3164              $backtrace = debug_backtrace();              $backtrace = debug_backtrace();
3165          }          }
3166          $from = format_backtrace($backtrace, CLI_SCRIPT);          $from = format_backtrace($backtrace, CLI_SCRIPT);
3167          if ($CFG->debugdisplay || isset($UNITTEST->running)) {          if (!empty($UNITTEST->running)) {
3168                  // When the unit tests are running, any call to trigger_error                  // When the unit tests are running, any call to trigger_error
3169                  // is intercepted by the test framework and reported as an exception.                  // is intercepted by the test framework and reported as an exception.
3170                  // Therefore, we cannot use trigger_error during unit tests.                  // Therefore, we cannot use trigger_error during unit tests.
3171                  // At the same time I do not think we should just discard those messages,                  // At the same time I do not think we should just discard those messages,
3172                  // so displaying them on-screen seems like the only option. (MDL-20398)                  // so displaying them on-screen seems like the only option. (MDL-20398)
3173                echo '<div class="notifytiny">' . $message . $from . '</div>';
3174    
3175            } else if (NO_DEBUG_DISPLAY) {
3176                // script does not want any errors or debugging in output,
3177                // we send the info to error log instead
3178                error_log('Debugging: ' . $message . $from);
3179    
3180            } else if ($CFG->debugdisplay) {
3181              if (!defined('DEBUGGING_PRINTED')) {              if (!defined('DEBUGGING_PRINTED')) {
3182                  define('DEBUGGING_PRINTED', 1); // indicates we have printed something                  define('DEBUGGING_PRINTED', 1); // indicates we have printed something
3183              }              }
3184              echo '<div class="notifytiny">' . $message . $from . '</div>';              echo '<div class="notifytiny">' . $message . $from . '</div>';
3185    
3186          } else {          } else {
3187              trigger_error($message . $from, E_USER_NOTICE);              trigger_error($message . $from, E_USER_NOTICE);
3188          }          }
# Line 3182  Line 3191 
3191  }  }
3192    
3193  /**  /**
  * Disable debug messages from debugging(), while keeping PHP error reporting level as is.  
  *  
  * @global object  
  */  
 function disable_debugging() {  
     global $CFG;  
     $CFG->debug = $CFG->debug | 0x80000000; // switch the sign bit in integer number ;-)  
 }  
   
   
 /**  
3194   *  Returns string to add a frame attribute, if required   *  Returns string to add a frame attribute, if required
3195   *   *
3196   * @global object   * @global object

Legend:
Removed from v.1.1345  
changed lines
  Added in v.1.1346

Moodle CVS Admin
ViewVC Help
Powered by ViewVC 1.0.7