views_watchdog.module in Views Watchdog 6
Same filename and directory in other branches
Allows users to create customized lists and queries from watchdog entries.
File
views_watchdog.moduleView source
<?php
/**
* @file
* Allows users to create customized lists and queries from watchdog entries.
*/
/**
* Implementation of hook_views_api().
*/
function views_watchdog_views_api() {
$api = array(
'api' => 2,
'path' => drupal_get_path('module', 'views_watchdog') . '/views',
);
return $api;
}
/**
* Helper functions.
*/
function views_watchdog_get_severity($code = NULL, $item = NULL) {
static $severity = array();
if (!$severity) {
$severity[WATCHDOG_EMERG] = array(
'title' => t('Emergency'),
'text' => t('System is unusable.'),
'icon' => 'misc/watchdog-error.png',
'class' => 'dblog-emerg',
'arg' => 'emerg',
);
$severity[WATCHDOG_ALERT] = array(
'title' => t('Alert'),
'text' => t('Action must be taken immediately.'),
'icon' => 'misc/watchdog-error.png',
'class' => 'dblog-alert',
'arg' => 'alert',
);
$severity[WATCHDOG_CRITICAL] = array(
'title' => t('Critical'),
'text' => t('Critical conditions.'),
'icon' => 'misc/watchdog-error.png',
'class' => 'dblog-critical',
'arg' => 'critical',
);
$severity[WATCHDOG_ERROR] = array(
'title' => t('Error'),
'text' => t('Error conditions.'),
'icon' => 'misc/watchdog-error.png',
'class' => 'dblog-error',
'arg' => 'error',
);
$severity[WATCHDOG_WARNING] = array(
'title' => t('Warning'),
'text' => t('Warning conditions.'),
'icon' => 'misc/watchdog-warning.png',
'class' => 'dblog-warning',
'arg' => 'warning',
);
$severity[WATCHDOG_NOTICE] = array(
'title' => t('Notice'),
'text' => t('Normal but significant condition.'),
'icon' => '',
'class' => 'dblog-notice',
'arg' => 'notice',
);
$severity[WATCHDOG_INFO] = array(
'title' => t('Info'),
'text' => t('Informational messages.'),
'icon' => '',
'class' => 'dblog-info',
'arg' => 'info',
);
$severity[WATCHDOG_DEBUG] = array(
'title' => t('Debug'),
'text' => t('Debug-level messages.'),
'icon' => '',
'class' => 'dblog-debug',
'arg' => 'debug',
);
}
return $code ? $item ? $severity[$code][$item] : $severity[$code] : $severity;
}
function views_watchdog_get_severity_icon($code, $path) {
static $severity_icon = array();
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', $path, $title, $title) : '';
}
return $severity_icon[$code];
}
function views_watchdog_get_type() {
static $type = array();
if (!$type) {
$result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type');
while ($object = db_fetch_object($result)) {
$type[] = $object->type;
}
}
return $type;
}
function views_watchdog_format_message($message, $variables) {
return $variables === 'N;' ? $message : t($message, unserialize($variables));
}
Functions
Name![]() |
Description |
---|---|
views_watchdog_format_message | |
views_watchdog_get_severity | Helper functions. |
views_watchdog_get_severity_icon | |
views_watchdog_get_type | |
views_watchdog_views_api | Implementation of hook_views_api(). |