views_watchdog.module in Views Watchdog 7.3
Same filename and directory in other branches
This module extends the Views module and allows to create customized lists (pages, blocks, feeds) of watchdog entries.
File
views_watchdog.moduleView source
<?php
/**
* @file
* This module extends the Views module and allows to create customized lists
* (pages, blocks, feeds) of watchdog entries.
*/
/**
* Implements hook_help().
*/
function views_watchdog_help($path, $arg) {
switch ($path) {
case 'admin/help#views_watchdog':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Views Watchdog module extends the <a href="@views">Views</a> module and allows to create customized lists (pages, blocks, feeds) of watchdog entries. For more information, see the online handbook entry for <a href="@views_watchdog">Views Watchdog module</a>.', array(
'@views' => 'http://drupal.org/project/views',
'@views_watchdog' => 'http://drupal.org/project/views_watchdog',
)) . '</p>';
return $output;
}
}
/**
* Implements hook_views_api().
*/
function views_watchdog_views_api() {
$api = array(
'api' => 3,
'path' => drupal_get_path('module', 'views_watchdog') . '/views',
);
return $api;
}
/**
* Helper function; retrieves list of severity levels.
*/
function _views_watchdog_get_severity($code = NULL, $item = NULL) {
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['severity'] =& drupal_static(__FUNCTION__);
}
$severity =& $drupal_static_fast['severity'];
if (!isset($severity)) {
$severity[WATCHDOG_EMERGENCY] = array(
'title' => t('Emergency'),
'text' => t('System is unusable.'),
'icon' => 'misc/watchdog-error.png',
'arg' => 'emergency',
);
$severity[WATCHDOG_ALERT] = array(
'title' => t('Alert'),
'text' => t('Action must be taken immediately.'),
'icon' => 'misc/watchdog-error.png',
'arg' => 'alert',
);
$severity[WATCHDOG_CRITICAL] = array(
'title' => t('Critical'),
'text' => t('Critical conditions.'),
'icon' => 'misc/watchdog-error.png',
'arg' => 'critical',
);
$severity[WATCHDOG_ERROR] = array(
'title' => t('Error'),
'text' => t('Error conditions.'),
'icon' => 'misc/watchdog-error.png',
'arg' => 'error',
);
$severity[WATCHDOG_WARNING] = array(
'title' => t('Warning'),
'text' => t('Warning conditions.'),
'icon' => 'misc/watchdog-warning.png',
'arg' => 'warning',
);
$severity[WATCHDOG_NOTICE] = array(
'title' => t('Notice'),
'text' => t('Normal but significant condition.'),
'icon' => '',
'arg' => 'notice',
);
$severity[WATCHDOG_INFO] = array(
'title' => t('Info'),
'text' => t('Informational messages.'),
'icon' => '',
'arg' => 'info',
);
$severity[WATCHDOG_DEBUG] = array(
'title' => t('Debug'),
'text' => t('Debug-level messages.'),
'icon' => '',
'arg' => 'debug',
);
}
return $code ? $item ? $severity[$code][$item] : $severity[$code] : $severity;
}
/**
* Helper function; retrieves severity icon.
*/
function _views_watchdog_get_severity_icon($code, $path) {
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['severity_icon'] =& drupal_static(__FUNCTION__);
}
$severity_icon =& $drupal_static_fast['severity_icon'];
if (!isset($severity_icon[$code])) {
$path = trim($path);
$title = _views_watchdog_get_severity($code, 'title');
$severity_icon[$code] = !empty($path) && is_file($path) ? theme('image', array(
'path' => $path,
'alt' => $title,
'title' => $title,
)) : '';
}
return $severity_icon[$code];
}
/**
* Helper function; retrieves list of watchdog types.
*/
function _views_watchdog_get_type() {
$type =& drupal_static(__FUNCTION__);
if (!isset($type)) {
$type = array();
$result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type');
foreach ($result as $record) {
$type[] = $record->type;
}
}
return $type;
}
/**
* Helper function; formats watchdog message.
*/
function _views_watchdog_format_message($message, $variables) {
return $variables === 'N;' ? $message : t($message, unserialize($variables));
}
Functions
Name![]() |
Description |
---|---|
views_watchdog_help | Implements hook_help(). |
views_watchdog_views_api | Implements hook_views_api(). |
_views_watchdog_format_message | Helper function; formats watchdog message. |
_views_watchdog_get_severity | Helper function; retrieves list of severity levels. |
_views_watchdog_get_severity_icon | Helper function; retrieves severity icon. |
_views_watchdog_get_type | Helper function; retrieves list of watchdog types. |