1 dblog.admin.inc dblog_event($id)

Page callback: Displays details about a specific database log message.

Parameters

int $id: Unique ID of the database log message.

Return value

array|string: If the ID is located in the Database Logging table, a build array in the format expected by backdrop_render(); otherwise, an empty string.

See also

dblog_menu()

File

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

Code

function dblog_event($id) {
  $severity = watchdog_severity_levels();
  $result = db_query('SELECT w.*, u.name, w.uid FROM {watchdog} w LEFT JOIN {users} u ON w.uid = u.uid WHERE w.wid = :id', array(':id' => $id))->fetchObject();
  if ($dblog = $result) {
    if (!empty($dblog->uid) && empty($dblog->name)) {
      $user_label = t('User ID (deleted)');
      $user_info = $dblog->uid;
    }
    else {
      $user_label = t('User');
      $user_info = theme('username', array('account' => $dblog));
    }

    $rows = array(
      array(
        array('data' => t('Type'), 'header' => TRUE),
        t($dblog->type),
      ),
      array(
        array('data' => t('Date'), 'header' => TRUE),
        format_date($dblog->timestamp, 'long'),
      ),
      array(
        array('data' => $user_label, 'header' => TRUE),
        $user_info,
      ),
      array(
        array('data' => t('Location'), 'header' => TRUE),
        l($dblog->location, $dblog->location),
      ),
      array(
        array('data' => t('Referrer'), 'header' => TRUE),
        l($dblog->referer, $dblog->referer),
      ),
      array(
        array('data' => t('Message'), 'header' => TRUE),
        dblog_format_message($dblog),
      ),
      array(
        array('data' => t('Severity'), 'header' => TRUE),
        $severity[$dblog->severity],
      ),
      array(
        array('data' => t('Hostname'), 'header' => TRUE),
        check_plain($dblog->hostname),
      ),
      array(
        array('data' => t('Operations'), 'header' => TRUE),
        $dblog->link,
      ),
    );
    $build['dblog_table'] = array(
      '#theme' => 'table',
      '#rows' => $rows,
      '#attributes' => array('class' => array('dblog-event')),
    );
    return $build;
  }
  else {
    return '';
  }
}