1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| <?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); }
/** * Extend exceptions to email me on exception * * @author Mike Funk * @email mfunk@christianpublishing.com * * @file MY_Exceptions.php */
/** * MY_Exceptions class. * * @extends CI_Exceptions */ class MY_Exceptions extends CI_Exceptions {
// --------------------------------------------------------------------------
/** * extend log_exception to add emailing of php errors. * * @access public * @param string $severity * @param string $message * @param string $filepath * @param int $line * @return void */ function log_exception($severity, $message, $filepath, $line) { $ci =& get_instance(); $ci->config->load('gitlab'); if (config_item('gitlab')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, config_item('gitlab_api')); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'PRIVATE-TOKEN: ' . config_item('gitlab_private_token'), )); curl_setopt($ch, CURLOPT_POSTFIELDS, [ 'title' => $message, 'description' => '<pre>' . $message . '</pre>', 'assignee_id' => config_item('gitlab_assignee_id'), 'labels' => '捕虫器,错误', ]); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_VERBOSE, false); $response = curl_exec($ch); curl_close($ch); }
// do the rest of the codeigniter stuff parent::log_exception($severity, $message, $filepath, $line); }
// --------------------------------------------------------------------------
/** * replace short tags with values. * * @access private * @param string $content * @param string $severity * @param string $message * @param string $filepath * @param int $line * @return string */ private function _replace_short_tags($content, $severity, $message, $filepath, $line) { $content = str_replace('{{severity}}', $severity, $content); $content = str_replace('{{message}}', $message, $content); $content = str_replace('{{filepath}}', $filepath, $content); $content = str_replace('{{line}}', $line, $content);
return $content; }
// -------------------------------------------------------------------------- }
|