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 140

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);
  $full = drush_get_option('full', 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.'));
  }
  $header = array(
    dt('Id'),
    dt('Date'),
    dt('Severity'),
    dt('Type'),
    dt('Message'),
  );
  while ($result = drush_db_fetch_object($rsc)) {
    $row = core_watchdog_format_result($result, $full);
    $table[] = array(
      $row->wid,
      $row->date,
      $row->severity,
      $row->type,
      $row->message,
    );
  }
  if (empty($table)) {
    return drush_log(dt('No log messages available.'), 'ok');
  }
  else {
    drush_log(dt('Most recent !count watchdog log messages:', array('!count' => $count)));
    if ($tail) {
      $table = array_reverse($table);
    }
    array_unshift($table, $header);
    $tbl = drush_print_table($table, TRUE);
  }

  if ($tail) {
    // We will 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.
    $last = array_pop($table);
    $last_wid = $last[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, $full);
        $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);
    }
  }
  else {
    print "\n";
  }
}