• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send Codeigniter error messages to public_thml/error_log

#1
views/errors/error_db.php
Code:
<body>
   <div id="container">
       <h1><?php echo $heading; ?></h1>
       <?php echo $message; ?>
   </div>
</body>

views/errors/error_php.php
Code:
<h4>A PHP Error was encountered</h4>

<p>Severity: <?php echo $severity; ?></p>
<p>Message:  <?php echo $message; ?></p>
<p>Filename: <?php echo $filepath; ?></p>
<p>Line Number: <?php echo $line; ?></p>

I want to overide this view file to show custom messages ($message, $filepath and $line in error_db.php and error_php.php). I don't want to serve a lot information about my files and db data structure.

But when I do that, my visitor can't trease what is causing error, so information can't provided by them to admin. In the same time, error messages provided here have a more details, make it easy to find a problerm that causing php and db error; than a messages usually I get in public_html/error_log file when some error encountered.

Example:

Error message in error log:
Code:
[02-Aug-2017 06:41:29 America/Chicago] PHP Fatal error:  Call to a member function num_rows() on boolean in /home9/markzuckberg/public_html/application/libraries/my_login.php on line 23

Error message in view:
Code:
Error Number: 1146

Table 'facebook.myusertable' doesn't exist

SELECT * FROM `myusertable` WHERE `mail` = '[email protected]' AND `password` = 'd3456.$789c09d$.3c1c19e8e1c$.de'

Filename: libraries/my_login.php

Line Number: 21

How to send this PHP and DB error messages to error_log? When visitor facing any error. So by that, i can check any error on my application easily with more details without reported.

maybe in this format for DB Error:
Code:
[02-Aug-2017 06:41 America/Chicago] Table 'facebook.myusertable' doesn't exist - SELECT * FROM `myusertable` WHERE `mail` = '[email protected]' AND `password` = 'd3456.$789c09d$.3c1c19e8e1c$.de' - in libraries/my_login.php - at line 21
Reply


Messages In This Thread
Send Codeigniter error messages to public_thml/error_log - by Afham Aqasyah - 08-02-2017, 09:27 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.