Skip to content

Instantly share code, notes, and snippets.

@msonnabaum
Created May 20, 2011 05:38
Show Gist options
  • Select an option

  • Save msonnabaum/982414 to your computer and use it in GitHub Desktop.

Select an option

Save msonnabaum/982414 to your computer and use it in GitHub Desktop.
diff --git a/drush.php b/drush.php
index 7a427af..c834dd0 100755
--- a/drush.php
+++ b/drush.php
@@ -113,7 +113,7 @@ function drush_main() {
$return = '';
}
- if (drush_get_context('DRUSH_DEBUG')) {
+ if (drush_get_context('DRUSH_DEBUG') && !drush_get_context('DRUSH_QUIET')) {
drush_print_timers();
}
drush_log(dt('Peak memory usage was !peak', array('!peak' => drush_format_size(memory_get_peak_usage()))), 'memory');
diff --git a/includes/drush.inc b/includes/drush.inc
index c527d2d..c9d8292 100644
--- a/includes/drush.inc
+++ b/includes/drush.inc
@@ -1128,7 +1128,7 @@ function drush_print_timers() {
}
$table[] = array($name, $cum, $count, $avg);
}
- drush_print_table($table, TRUE);
+ drush_print_table($table, TRUE, array(), 'STDERR');
}
}
diff --git a/includes/output.inc b/includes/output.inc
index 6854130..f2e69a9 100644
--- a/includes/output.inc
+++ b/includes/output.inc
@@ -123,12 +123,14 @@ function drush_html_to_text($html, $allowed_tags = NULL) {
* @param $widths
* The widths of each column (in characters) to use - if not specified this
* will be determined automatically, based on a "best fit" algorithm.
- * @param $output_file
- * File to write output to. STDOUT used if not specified.
+ * @param $handle
+ * File handle to write to. NULL will write
+ * to standard output, STDERR will write to the standard
+ * error. See http://php.net/manual/en/features.commandline.io-streams.php
* @return $tbl
* Use $tbl->getTable() to get the output from the return value.
*/
-function drush_print_table($rows, $header = FALSE, $widths = array(), $output_file = NULL) {
+function drush_print_table($rows, $header = FALSE, $widths = array(), $handle = NULL) {
$tbl = new Console_Table(CONSOLE_TABLE_ALIGN_LEFT , '');
$auto_widths = drush_table_column_autowidth($rows, $widths);
@@ -153,12 +155,8 @@ function drush_print_table($rows, $header = FALSE, $widths = array(), $output_fi
if (!stristr(PHP_OS, 'WIN')) {
$output = str_replace("\r\n", PHP_EOL, $output);
}
- if ($output_file == NULL) {
- drush_print($output);
- }
- else {
- file_put_contents($output_file, $output, FILE_APPEND);
- }
+
+ drush_print($output, 0, $handle);
return $tbl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment