Welcome Guest, Not a member yet? Register   Sign In
logging to a database
#1

[eluser]fatTireFreak[/eluser]
I'm new to CI and I want to extend the log class and put my logs in a database. I want to track errors as well as usage data and query it. Depending on traffic I'll move the data out and truncate the log table to keep it from getting too large.

I created a MY_Log.php library and added my own write_log function into it. It basically seems like a simple task to me, but I can't get the CI instance in MY_Log.php. If I do $CI =& get_instance(); I get:

Fatal error: Call to undefined function get_instance()

I'm guessing that the core functionality hasn't loaded yet when I hit write_log. If I reduce the logging threshold so that it doesn't log debug messages and move the get_instance call down below this line:

Code:
if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
        {
            return FALSE;
        }

Has anyone hit this issue and or found a work around.

Thanks in advance.


Messages In This Thread
logging to a database - by El Forum - 05-26-2010, 06:02 PM
logging to a database - by El Forum - 05-26-2010, 08:30 PM
logging to a database - by El Forum - 05-27-2010, 03:40 PM
logging to a database - by El Forum - 05-27-2010, 05:31 PM
logging to a database - by El Forum - 10-16-2010, 11:50 AM
logging to a database - by El Forum - 10-16-2010, 01:14 PM
logging to a database - by El Forum - 10-16-2010, 01:17 PM
logging to a database - by El Forum - 10-17-2010, 07:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB