/** * @static * @param \Difra\Exception|\exception $exception */ public static function sendNotification($exception) { // TODO: merge this method with Exception::sendNotification() // don't send notifications on development environment if (!Envi::isProduction()) { return; } $notificationMail = Debugger::getNotificationMail(); // no notification mail is set if (!$notificationMail) { return; } $date = date('r'); $server = print_r($_SERVER, true); $post = print_r($_POST, true); $cookie = print_r($_COOKIE, true); $user = Auth::getInstance()->getEmail(); $uri = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '-'; $host = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '-'; $exceptionClass = get_class($exception); $text = <<<MSG Page:\t{$uri} Time:\t{$date} Host:\t{$host} User:\t{$user} Type: {$exceptionClass} File:\t{$exception->getFile()} Line:\t{$exception->getLine()} Exception: {$exception->getMessage()} {$exception->getTraceAsString()} \$_SERVER: {$server} \$_POST: {$post} \$_COOKIE: {$cookie} MSG; mail($notificationMail, $host . ': ' . $exception->getMessage(), $text); }