summaryrefslogtreecommitdiffstats
path: root/system/core/Log.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2013-02-15 21:30:31 +0100
committerAndrey Andreev <narf@bofh.bg>2013-02-15 21:30:31 +0100
commita107a0fd79d0ee5f6292138a76398ed390041710 (patch)
tree207176937ce460debb5fb6c83e42661468c90bdf /system/core/Log.php
parentd11673b5fc09c28e06333946db0a3841eeea4024 (diff)
Fix some stuff from recent pull requests
Diffstat (limited to 'system/core/Log.php')
-rw-r--r--system/core/Log.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/system/core/Log.php b/system/core/Log.php
index 0749de8ba..a84d3dc22 100644
--- a/system/core/Log.php
+++ b/system/core/Log.php
@@ -73,6 +73,13 @@ class CI_Log {
protected $_date_fmt = 'Y-m-d H:i:s';
/**
+ * Filename extension
+ *
+ * @var string
+ */
+ protected $_file_ext;
+
+ /**
* Whether or not the logger can write to the log files
*
* @var bool
@@ -86,8 +93,10 @@ class CI_Log {
*/
protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4);
+ // --------------------------------------------------------------------
+
/**
- * Initialize Logging class
+ * Class constructor
*
* @return void
*/
@@ -96,8 +105,8 @@ class CI_Log {
$config =& get_config();
$this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/';
-
- $this->_log_ext = ($config['log_file_extension'] !== '') ? ltrim($config['log_file_extension'], '.') : $this->_log_ext;
+ $this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '')
+ ? ltrim($config['log_file_extension'], '.') : 'php';
file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE);
@@ -149,15 +158,16 @@ class CI_Log {
return FALSE;
}
- $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php';
- $message = '';
+ $filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext;
+ $message = '';
if ( ! file_exists($filepath))
{
$newfile = TRUE;
- if($this->_log_ext === 'php')
+ // Only add protection to php files
+ if ($this->_file_ext === 'php')
{
- $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n";
+ $message .= "<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>\n\n";
}
}