Logging errors to a database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Logging errors to a database (/showthread.php?tid=59778) |
Logging errors to a database - El Forum - 11-16-2013 [eluser]jonez[/eluser] Hi I'm trying to log PHP error's and 404's to a database. I've tried to overload CI_Log's write_log and CI_Exceptions show_error, but in both cases the main CI object hasn't been created so I can't use DB methods. I tried wrapping get_instance in a try/catch, but it still fails. I'm assuming the error handlers are setup this way to catch errors in core files. Does anyone have a clever solution? I'm not opposed to using a library over a core extension as long as it doesn't require custom error handling in methods. Ideally I'd like errors to propagate as they do now and simply add logging to a database. Thanks! Logging errors to a database - El Forum - 11-21-2013 [eluser]jonez[/eluser] My initial solution for logging PHP errors to a database using CI3-dev: db.error Code: CREATE TABLE `error` ( /application/config/hooks.php Code: $hook['post_controller_constructor'][] = array( /application/hooks/log.php Code: <?php /application/core/MY_Log.php Code: <?php if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' ); |