예제 #1
0
 public static function alert($alertMessage)
 {
     $to = sfConfig::get('app_sfErrorNotifier_emailTo');
     if (!$to) {
         // this environment is not set to notify exceptions
         return;
     }
     $context = sfContext::getInstance();
     $env = 'n/a';
     if ($conf = sfContext::getInstance()->getConfiguration()) {
         $env = $conf->getEnvironment();
     }
     $data = array();
     $data['moduleName'] = $context->getModuleName();
     $data['actionName'] = $context->getActionName();
     $data['uri'] = $context->getRequest()->getUri();
     $serverHttpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'unknown http host';
     $subject = "ALERT: {$serverHttpHost} - {$env} - {$alertMessage}";
     $mail = new sfErrorNotifierMail($subject, $data, null, $context);
     $mail->notify(sfConfig::get('app_sfErrorNotifier_emailFormat', 'html'));
 }
 public static function notify(sfEvent $event)
 {
     $to = sfConfig::get('app_sfErrorNotifier_emailTo');
     if (!$to) {
         // this environment is not set to notify exceptions
         return;
     }
     $exception = $event->getSubject();
     $context = sfContext::getInstance();
     $env = 'n/a';
     if ($conf = sfContext::getInstance()->getConfiguration()) {
         $env = $conf->getEnvironment();
     }
     $data = array();
     $data['className'] = get_class($exception);
     $data['message'] = !is_null($exception->getMessage()) ? $exception->getMessage() : 'n/a';
     $data['moduleName'] = $context->getModuleName();
     $data['actionName'] = $context->getActionName();
     $data['uri'] = $context->getRequest()->getUri();
     $subject = "ERROR: {$_SERVER['HTTP_HOST']} Exception - {$env} - {$data['message']}";
     $mail = new sfErrorNotifierMail($to, $subject, $data, $exception, $context);
     $mail->notify();
 }