function drush_core_watchdog_show_many

8.0.x watchdog.drush.inc drush_core_watchdog_show_many($filter = NULL)
6.x watchdog.drush.inc drush_core_watchdog_show_many($filter = NULL)
7.x watchdog.drush.inc drush_core_watchdog_show_many($filter = NULL)
3.x watchdog.drush.inc drush_core_watchdog_show_many($filter = NULL)
4.x watchdog.drush.inc drush_core_watchdog_show_many($filter = NULL)
5.x watchdog.drush.inc drush_core_watchdog_show_many($filter = NULL)
master watchdog.drush.inc drush_core_watchdog_show_many($filter = NULL)

Print a table of watchdog messages.

Parameters

$filter: String to filter the message's text by.

2 calls to drush_core_watchdog_show_many()
drush_core_watchdog_list in commands/core/watchdog.drush.inc
Command callback.
drush_core_watchdog_show in commands/core/watchdog.drush.inc
Command callback.

File

commands/core/watchdog.drush.inc, line 151

Code

function drush_core_watchdog_show_many($filter = NULL) {
  $count = drush_get_option('count', 10);
  $type = drush_get_option('type');
  $severity = drush_get_option('severity');
  $tail = drush_get_option('tail', FALSE);
  $extended = drush_get_option('extended', FALSE);

  $where = core_watchdog_query($type, $severity, $filter);
  if ($where === FALSE) {
    return drush_log(dt('Aborting.'));
  }
  $rsc = drush_db_select('watchdog', '*', $where['where'], $where['args'], 0, $count, 'wid', 'DESC');
  if ($rsc === FALSE) {
    return drush_log(dt('Aborting.'));
  }
  $table = array();
  while ($result = drush_db_fetch_object($rsc)) {
    $row = core_watchdog_format_result($result, $extended);
    $table[$row->wid] = (array) $row;
  }
  if (empty($table) && !$tail) {
    drush_log(dt('No log messages available.'), 'ok');
    return array();
  }
  else {
    drush_log(dt('Most recent !count watchdog log messages:', array('!count' => $count)));
  }
  if ($tail) {
    $field_list = array(
      'wid' => 'ID',
      'date' => 'Date',
      'severity' => 'Severity',
      'type' => 'Type',
      'message' => 'Message',
    );
    $table = array_reverse($table);
    $table_rows = drush_rows_of_key_value_to_array_table($table, $field_list, array());
    $tbl = drush_print_table($table_rows, TRUE);
    // Reuse the table object to display each line generated while in tail mode.
    // To make it possible some hacking is done on the object:
    // remove the header and reset the rows on each iteration.
    $tbl->_headers = NULL;
    // Obtain the last wid. If the table has no rows, start at 0.
    if (count($table_rows) > 1) {
      $last = array_pop($table_rows);
      $last_wid = $last[0];
    }
    else {
      $last_wid = 0;
    }
    // Adapt the where snippet.
    if ($where['where'] != '') {
      $where['where'] .= ' AND ';
    }
    $where['where'] .= 'wid > :wid';
    // sleep-delay
    $sleep_delay = drush_get_option('sleep-delay', 1);
    while (TRUE) {
      $where['args'][':wid'] = $last_wid;
      $table = array();
      // Reset table rows.
      $tbl->_data = array();
      $rsc = drush_db_select('watchdog', '*', $where['where'], $where['args'], NULL, NULL, 'wid', 'ASC');
      while ($result = drush_db_fetch_object($rsc)) {
        $row = core_watchdog_format_result($result, $extended);
        $table[] = array(
          $row->wid,
          $row->date,
          $row->severity,
          $row->type,
          $row->message,
        );
        #$tbl->addRow(array($row->wid, $row->date, $row->severity, $row->type, $row->message));
        $last_wid = $row->wid;
      }
      $tbl->addData($table);
      print $tbl->_buildTable();
      sleep($sleep_delay);
    }
  }
  return $table;
}