| 1 |
<?php |
<?php |
| 2 |
/* $Id: watchdognotify.module,v 1.1 2005/08/28 17:29:12 ee Exp $ */ |
/* $Id: watchdognotify.module,v 1.2 2005/09/23 14:29:09 ee Exp $ */ |
| 3 |
/** |
/** |
| 4 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 5 |
*/ |
*/ |
| 8 |
$items = array(); |
$items = array(); |
| 9 |
$items[] = array('path' => 'subscription/add/watchdog', |
$items[] = array('path' => 'subscription/add/watchdog', |
| 10 |
'title' => t('add watchdog subscription'), |
'title' => t('add watchdog subscription'), |
| 11 |
'access' => true, |
'access' => user_access('access administration pages'), |
| 12 |
'callback' => 'watchdognotify_subscribe', |
'callback' => 'watchdognotify_subscribe', |
| 13 |
'type' => MENU_CALLBACK); |
'type' => MENU_CALLBACK); |
| 14 |
return $items; |
return $items; |
| 20 |
drupal_goto('user/'.$user->uid.'/subscriptions'); |
drupal_goto('user/'.$user->uid.'/subscriptions'); |
| 21 |
} |
} |
| 22 |
/* |
/* |
| 23 |
* Implement hook_subscrition(); |
* Implement hook_subscription(); |
| 24 |
*/ |
*/ |
| 25 |
function watchdognotify_subscription($op, $arg1 = null, $arg2 = null) { |
function watchdognotify_subscription($op, $arg1 = null, $arg2 = null) { |
| 26 |
if ($op == 'cron') { |
if ($op == 'cron') { |
| 36 |
$formatters[] = array('name' => 'Watchdog formatter', 'object' => 'watchdog', 'channel' => '*', 'weight' => 20, 'handler' => 'watchdognotify_formatter'); |
$formatters[] = array('name' => 'Watchdog formatter', 'object' => 'watchdog', 'channel' => '*', 'weight' => 20, 'handler' => 'watchdognotify_formatter'); |
| 37 |
return $formatters; |
return $formatters; |
| 38 |
} |
} |
| 39 |
if ($op == 'special') { |
if ($op == 'special' && user_access('access administration pages')) { |
| 40 |
return '<p>'.l("Subscribe to errors", 'subscription/add/watchdog').'</p>'; |
return l('Subscribe to significant site errors', 'subscription/add/watchdog'); |
| 41 |
} |
} |
| 42 |
} |
} |
| 43 |
function watchdognotify_formatter($object, $type) { |
function watchdognotify_formatter($object, $type) { |
| 44 |
return wordwrap('['. format_date($object['timestamp'], 'small') .']['. $object['hostname'] .']ERROR: '. $object['message'] ."\n", 72); |
return wordwrap('['. format_date($object['timestamp'], 'small') .']['. $object['hostname'] .']ERROR: '. $object['message'] ."\n", 72); |