1 dblog.admin.inc dblog_overview()

Page callback: Displays a listing of database log messages.

Messages are truncated at the length determined by the 'log_max_length' setting. Full-length messages can be viewed on the message details page.

See also

dblog_clear_log_form()

dblog_event()

dblog_filter_form()

dblog_menu()

File

core/modules/dblog/dblog.admin.inc, line 18
Admin page callbacks for the Database Logging module.

Code

function dblog_overview() {
  $filter = dblog_build_filter_query();
  $rows = array();
  $classes = watchdog_severity_levels('name');
  foreach ($classes as $key => $value) {
    $classes[$key] = 'dblog-' . $value;
  }

  $build['dblog_filter_form'] = backdrop_get_form('dblog_filter_form');

  $header = array(
    '', // Icon column.
    array('data' => t('Type'), 'field' => 'w.type', 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)),
    array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc', 'class' => array(RESPONSIVE_PRIORITY_LOW)),
    t('Message'),
    array('data' => t('User'), 'field' => 'u.name', 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)),
    array('data' => t('Operations'), 'class' => array(RESPONSIVE_PRIORITY_LOW)),
  );

  $query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
  $query->leftJoin('users', 'u', 'w.uid = u.uid');
  $query
  ->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link'))
    ->addField('u', 'name');
  if (!empty($filter['where'])) {
    $query->where($filter['where'], $filter['args']);
  }
  $result = $query
  ->limit(50)
    ->orderByHeader($header)
    ->execute();

  foreach ($result as $dblog) {
    if (!empty($dblog->uid) && empty($dblog->name)) {
      $user_info = t('Deleted User');
    }
    else {
      $user_info = theme('username', array('account' => $dblog));
    }

    $log_date_format = config_get('system.core', 'log_date_format');
    $rows[] = array('data' =>
      array(
        // Cells
        array('class' => 'icon'),
        t($dblog->type),
        format_date($dblog->timestamp, 'custom', $log_date_format),
        dblog_format_message($dblog, TRUE),
        $user_info,
        filter_xss($dblog->link),
      ),
      // Attributes for tr
      'class' => array(backdrop_html_class('dblog-' . $dblog->type), $classes[$dblog->severity]),
    );
  }

  $build['dblog_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')),
    '#empty' => t('No log messages available.'),
  );
  $build['dblog_pager'] = array('#theme' => 'pager');

  $build['dblog_clear_log_form'] = backdrop_get_form('dblog_clear_log_form');

  return $build;
}