summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-08-21 23:48:35 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-08-21 23:48:35 +0200
commitd66affd7e518ac4dd21c77e5344680c5217ff5e5 (patch)
treec0ee437ec6e18ff7809ed02cc1922207985bb8a1
parent60051f273a4f34f679e7d2627dc7af7f130ac102 (diff)
parent333f9f98edeb11915c168ea4a05b9b76d64d9576 (diff)
Merge pull request #253 from chonthu/develop
added ability to log certain error types, not all under a threshold
-rw-r--r--application/config/config.php4
-rw-r--r--system/libraries/Log.php21
-rw-r--r--user_guide/changelog.html1
3 files changed, 21 insertions, 5 deletions
diff --git a/application/config/config.php b/application/config/config.php
index 1ec65435e..7554f994a 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -176,6 +176,10 @@ $config['directory_trigger'] = 'd'; // experimental not currently in use
| 3 = Informational Messages
| 4 = All Messages
|
+| You can also pass in a array with threshold levels to show individual error types
+|
+| array(2) = Debug Messages, without Error Messages
+|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 9f1db76ba..bf10d4727 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -27,10 +27,12 @@
class CI_Log {
protected $_log_path;
- protected $_threshold = 1;
- protected $_date_fmt = 'Y-m-d H:i:s';
- protected $_enabled = TRUE;
- protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4');
+ protected $_threshold = 1;
+ protected $_threshold_max = 0;
+ 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');
/**
* Constructor
@@ -50,6 +52,11 @@ class CI_Log {
{
$this->_threshold = $config['log_threshold'];
}
+ elseif (is_array($config['log_threshold']))
+ {
+ $this->_threshold = $this->_threshold_max;
+ $this->_threshold_array = array_flip($config['log_threshold']);
+ }
if ($config['log_date_format'] != '')
{
@@ -80,9 +87,13 @@ class CI_Log {
if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
{
- return FALSE;
+ if (empty($this->_threshold_array) OR ! isset($this->_threshold_array[$this->_levels[$level]]))
+ {
+ return FALSE;
+ }
}
+
$filepath = $this->_log_path.'log-'.date('Y-m-d').'.php';
$message = '';
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 301b264c4..9d8fd2b54 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -66,6 +66,7 @@ Change Log
<li>General Changes
<ul>
<li class="reactor">Callback validation rules can now accept parameters like any other validation rule.</li>
+ <li class="reactor">Ability to log certain error types, not all under a threshold.</li>
</ul>
</li>
<li>Helpers