Hey everbody!
I want to extend the
/system/core/Log.php library with a couple of functions. One function should send a mail in case of an error via the custom function
sendMail() which is part of the
Custom_library.php.
Thus, I created the file
/application/core/MY_Log.php
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);
return $result;
}
}
The problem: I'm not able to load the
Custom_library.php. None of these approaches worked:
PHP Code:
//approach 1
$this->load->library('Custom_library');
//approach 2
$CI =& get_instance();
$CI->load->library('Custom_library');
Error message of the approach 2:
Code:
Fatal error: Uncaught Error: Class 'CI_Controller' not found in /home/gp/public_html/system/core/CodeIgniter.php:366 Stack trace: #0 /home/gp/public_html/application/core/MY_Log.php(13): get_instance() #1 /home/gp/public_html/system/core/Common.php(478): MY_Log->write_log('error', 'Severity: error...') #2 /home/gp/public_html/system/core/Exceptions.php(105): log_message('error', 'Severity: error...') #3 /home/gp/public_html/system/core/Common.php(662): CI_Exceptions->log_exception('error', 'Exception: Clas...', '/home/gp/public...', 366) #4 [internal function]: _exception_handler(Object(Error)) #5 {main} thrown in /home/gp/public_html/system/core/CodeIgniter.php on line 366
The question: Is it possible to load and utilize a Library in a Core Class?
Merci!