CodeIgniter Forums
log message of current class and function and line number - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: log message of current class and function and line number (/showthread.php?tid=63043)



log message of current class and function and line number - rchiu5hk - 09-18-2015

Dear all,

I am going to use log message function in codeigniter.
Is it possible to log current class and function and line number and error exception messages in the log so that I does not need to hard code these in the message??


RE: log message of current class and function and line number - mwhitney - 09-21-2015

CI3's default error and exception handlers already do this. If you look at /system/core/Common.php, the _exception_handler() function loads the Exceptions class and calls its log_exception() method, using the relevant methods on the $exception argument passed to the handler. At the very least, that should serve as an example for how to get the information from an Exception in your own code. The methods are also defined in PHP's manual, in the documentation of the Exception class.