示例#1
0
 /**
  * Constructor
  *
  * @access	public
  * @param	string	the log file path
  * @param	string	the error threshold
  * @param	string	the date formatting codes
  */
 function CI_Log()
 {
     $config =& _get_config();
     $this->log_path = $config['log_path'] != '' ? $config['log_path'] : BASEPATH . 'logs/';
     if (!is_dir($this->log_path) or !is_writable($this->log_path)) {
         $this->_enabled = FALSE;
     }
     if (is_numeric($config['log_threshold'])) {
         $this->_threshold = $config['log_threshold'];
     }
     if ($config['log_date_format'] != '') {
         $this->_date_fmt = $config['log_date_format'];
     }
 }
 /**
  * Constructor
  *
  * Sets the $config data from the primary config.php file as a class variable
  *
  * @access   public
  * @param   string    the config file name
  * @param   boolean  if configuration values should be loaded into their own section
  * @param   boolean  true if errors should just return false, false if an error message should be displayed
  * @return  boolean  if the file was successfully loaded or not
  */
 function CI_Config()
 {
     $this->config =& _get_config();
     log_message('debug', "Config Class Initialized");
 }
/**
* Exception Handler
*
* This is the custom exception handler we defined at the
* top of this file. The main reason we use this is permit 
* PHP errors to be logged in our own log files since we may 
* not have access to server logs. Since this function
* effectively intercepts PHP errors, however, we also need
* to display errors based on the current error_reporting level.
* We do that with the use of a PHP error template.
*
* @access	private
* @return	void
*/
function _exception_handler($severity, $message, $filepath, $line)
{
    // We don't bother with "strict" notices since they will fill up
    // the log file with information that isn't normally very
    // helpful.  For example, if you are running PHP 5 and you
    // use version 4 style class functions (without prefixes
    // like "public", "private", etc.) you'll get notices telling
    // you that these have been deprecated.
    if ($severity == E_STRICT) {
        return;
    }
    $error =& _load_class('CI_Exceptions');
    // Should we display the error?
    // We'll get the current error_reporting level and add its bits
    // with the severity bits to find out.
    if (($severity & error_reporting()) == $severity) {
        $error->show_php_error($severity, $message, $filepath, $line);
    }
    // Should we log the error?  No?  We're done...
    $config =& _get_config();
    if ($config['log_errors'] === FALSE) {
        return;
    }
    $error->log_exception($severity, $message, $filepath, $line);
}