Merge pull request #813 from narfbg/develop-log

Clean up the Log library
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 46c5b6e..7f3a307 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -44,7 +44,7 @@
 	protected $_threshold_array	= array();
 	protected $_date_fmt		= 'Y-m-d H:i:s';
 	protected $_enabled			= TRUE;
-	protected $_levels			= array('ERROR' => '1', 'DEBUG' => '2',  'INFO' => '3', 'ALL' => '4');
+	protected $_levels			= array('ERROR' => 1, 'DEBUG' => 2,  'INFO' => 3, 'ALL' => 4);
 
 	/**
 	 * Constructor
@@ -62,7 +62,7 @@
 
 		if (is_numeric($config['log_threshold']))
 		{
-			$this->_threshold = $config['log_threshold'];
+			$this->_threshold = (int) $config['log_threshold'];
 		}
 		elseif (is_array($config['log_threshold']))
 		{
@@ -97,12 +97,10 @@
 
 		$level = strtoupper($level);
 
-		if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
+		if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
+			AND ! isset($this->_threshold_array[$this->_levels[$level]]))
 		{
-			if (empty($this->_threshold_array) OR ! isset($this->_threshold_array[$this->_levels[$level]]))
-			{
-				return FALSE;
-			}
+			return FALSE;
 		}
 
 
@@ -112,7 +110,7 @@
 		if ( ! file_exists($filepath))
 		{
 			$newfile = TRUE;
-			$message .= "<"."?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
+			$message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
 		}
 
 		if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))