function log_message($level = 2, $message, $php_error = FALSE)
{
    global $config;
    if ($config['log_errors'] === FALSE) {
        return;
    }
    if (!class_exists('_Log')) {
        include_once BASEPATH . 'libraries/Log.php';
    }
    if (!isset($LOG)) {
        $LOG = new _Log($config['log_path'], $config['log_threshold'], $config['log_date_format']);
    }
    $LOG->write_log($level, $message, $php_error);
}