summaryrefslogtreecommitdiffstats
path: root/system/core/Log.php
diff options
context:
space:
mode:
authorDaniel Hunsaker <danhunsaker@gmail.com>2013-02-22 21:49:33 +0100
committerDaniel Hunsaker <danhunsaker@gmail.com>2013-02-22 21:49:33 +0100
commit44a6d1da2be916fe0f23a3ea4d5fcb391d7f65dd (patch)
tree31549ebf6ea5ea98e4347eb640d1caa685316f3e /system/core/Log.php
parent353f9834adf3f44c6c7a0f924089bb2b43360404 (diff)
parenteb291c1d1e1116a4420fa30e587adeea0451eeb7 (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into feature/exit-status
Diffstat (limited to 'system/core/Log.php')
-rw-r--r--system/core/Log.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/system/core/Log.php b/system/core/Log.php
index cd3c17e1e..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,6 +105,8 @@ class CI_Log {
$config =& get_config();
$this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/';
+ $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);
@@ -147,13 +158,17 @@ 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;
- $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n";
+ // Only add protection to php files
+ if ($this->_file_ext === 'php')
+ {
+ $message .= "<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>\n\n";
+ }
}
if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
@@ -179,4 +194,4 @@ class CI_Log {
}
/* End of file Log.php */
-/* Location: ./system/libraries/Log.php */ \ No newline at end of file
+/* Location: ./system/core/Log.php */ \ No newline at end of file