Welcome Guest, Not a member yet? Register   Sign In
[Solved] Codeigniter: Load Library in a Core Class
#11

I would say that in the most cases it won't make sense and it is more advisable to only send an email in case of some particular processes.

In this specific project I want to receive an email in case of an error (no information or debug message) on the production environment. The reason for that is that I do not want to monitor the project all the time. Thus, I adjusted the above posted code slightly:

PHP Code:
class MY_Log extends CI_Log {

 
 public function __construct()
 
 {
 
   parent::__construct();
 
 }

 
 public function write_log($level$msg)
 
 {
 
   $result parent::write_log($level$msg);

 
   //SEND MAIL
 
   if($level == 'error' && ENVIRONMENT == 'production')
 
   {
 
     require_once(BASE_PATH.'application/libraries/PHPMailer/PHPMailerAutoload.php');
 
     
      $mail 
= new PHPMailer;
 
     $mail->CharSet "UTF-8";
 
     $mail->isSMTP();
 
     $mail->Subject $level;
      $mail->Body $msg;
 
     //additional email stuff...

 
     $mail->send();
 
   }
 
   //END SEND MAIL

 
   return is_int($result);
 
 }



Thank you for your input
Reply


Messages In This Thread
RE: Codeigniter: Load Library in a Core Class - by SirGecco - 11-03-2016, 03:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB