Blame | Last modification | View Log | RSS feed
<?php/*** MY_Log Class** This library extends the native Log library.* It adds the function to have the log messages being emailed when they have been outputted to the log file.** @package CodeIgniter* @subpackage Libraries* @category Logging* @author Upkar Singh*/class MY_Log {/*** Constructor** @access public*/var $CI;var $to;var $from;function __construct(){parent::__construct();$this->CI =& get_instance();////$params = array('protocol' => 'smtp','smtp_host' => 'ssl://smtp.gmail.com','smtp_port' => 465,'smtp_user' => 'upanjeta66@gmail.com','smtp_pass' => 'sanchita07');$this->CI->load->library('email',$config);$this->CI->email->set_newline("\r\n");}/*** Write Log File** Calls the native write_log() method and then sends an email if a log message was generated.** @access public* @param string the error level* @param string the error message* @param bool whether the error is a native PHP error* @return bool*/// function test(){//// $this->email->from('upanjeta66@gmail.com', 'Upkar Singh');// $this->email->to('upkar@letsgomo.com');// $this->email->subject('This is an email test');// $this->email->message('It is working. Great!');//// //$path = $this->config->item('server_root');// //$file = $path . '/ci_day3/attachments/yourInfo.txt';//// //$this->email->attach($file);//// if($this->email->send())// {// echo 'Your email was sent, fool.';// }//// else// {// show_error($this->email->print_debugger());// }// }function test(){echo "in test";}function write_log($level = 'error', $msg, $php_error = FALSE){$result = parent::write_log($level, $msg, $php_error);$result = TRUE;if ($result == TRUE && strtoupper($level) == 'ERROR') {$message = "The API has failed. \n\n";$message .= $level.' - '.date('m/d/Y h:i:s a', time()). ' --> '.$msg."\n";$to = 'akant@letsgomo.com';$subject = 'The API failed at '.date('m/d/Y h:i:s a', time());$headers = 'From: Upkar Singh <upkar@letsgomo.com>' . "\r\n";$headers .= 'Content-type: text/plain; charset=utf-8\r\n';mail($to, $subject, $message, $headers);}return $result;}}?>