Skip to content
Browse files

Merge branch 'MDL-30966-print-object_22_STABLE' of git://github.com/m…

…udrd8mz/moodle into MOODLE_22_STABLE
  • Loading branch information...
2 parents 7e20d8e + b886841 commit f35cacdc8366bd799af1dcb85b87bd906ee0067a @stronk7 stronk7 committed Jan 9, 2012
Showing with 13 additions and 6 deletions.
  1. +13 −6 lib/datalib.php
View
19 lib/datalib.php
@@ -1957,19 +1957,26 @@ function count_login_failures($mode, $username, $lastlogin) {
/// GENERAL HELPFUL THINGS ///////////////////////////////////
/**
- * Dump a given object's information in a PRE block.
+ * Dumps a given object's information for debugging purposes
*
- * Mostly just used for debugging.
+ * When used in a CLI script, the object's information is written to the standard
+ * error output stream. When used in a web script, the object is dumped to a
+ * pre-formatted block with the "notifytiny" CSS class.
*
* @param mixed $object The data to be printed
- * @return void OUtput is echo'd
+ * @return void output is echo'd
*/
function print_object($object) {
- echo '<pre class="notifytiny">';
+
// we may need a lot of memory here
raise_memory_limit(MEMORY_EXTRA);
- echo s(print_r($object, true));
- echo '</pre>';
+
+ if (CLI_SCRIPT) {
+ fwrite(STDERR, print_r($object, true));
+ fwrite(STDERR, PHP_EOL);
+ } else {
+ echo html_writer::tag('pre', s(print_r($object, true)), array('class' => 'notifytiny'));
+ }
}
/**

0 comments on commit f35cacd

Please sign in to comment.
Something went wrong with that request. Please try again.