From b82bc3a016ce01dfeb993da5918853625a40af86 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 09:12:58 -0400 Subject: Fix Cache, Image_lib and Log libraries --- system/libraries/Log.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'system/libraries/Log.php') diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 66f9ebff9..c10363a2e 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -36,14 +36,60 @@ */ class CI_Log { + /** + * Path to save log files + * + * @var string + */ protected $_log_path; + + /** + * Level of logging + * + * @var int + */ protected $_threshold = 1; + + /** + * Highest level of logging + * + * @var int + */ protected $_threshold_max = 0; + + /** + * Array of threshold levels to log + * + * @var array + */ protected $_threshold_array = array(); + + /** + * Format of timestamp for log files + * + * @var string + */ protected $_date_fmt = 'Y-m-d H:i:s'; + + /** + * Whether or not the logger can write to the log files + * + * @var bool + */ protected $_enabled = TRUE; + + /** + * Predefined logging levels + * + * @var array + */ protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4); + /** + * Initialize Logging class + * + * @return void + */ public function __construct() { $config =& get_config(); -- cgit v1.2.3-24-g4f1b From 5645479c622eb36cf9869797896dc0921568c4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:32:19 +0300 Subject: Clean up the libraries --- system/libraries/Log.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'system/libraries/Log.php') diff --git a/system/libraries/Log.php b/system/libraries/Log.php index c10363a2e..51ce43dc7 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -42,42 +42,42 @@ class CI_Log { * @var string */ protected $_log_path; - + /** * Level of logging * * @var int */ protected $_threshold = 1; - + /** * Highest level of logging * * @var int */ protected $_threshold_max = 0; - + /** * Array of threshold levels to log * * @var array */ protected $_threshold_array = array(); - + /** * Format of timestamp for log files * * @var string */ protected $_date_fmt = 'Y-m-d H:i:s'; - + /** * Whether or not the logger can write to the log files * * @var bool */ protected $_enabled = TRUE; - + /** * Predefined logging levels * @@ -88,7 +88,7 @@ class CI_Log { /** * Initialize Logging class * - * @return void + * @return void */ public function __construct() { @@ -151,7 +151,7 @@ class CI_Log { 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)) @@ -159,7 +159,7 @@ class CI_Log { return FALSE; } - $message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n"; + $message .= $level.' '.($level === 'INFO' ? ' -' : '-').' '.date($this->_date_fmt).' --> '.$msg."\n"; flock($fp, LOCK_EX); fwrite($fp, $message); -- cgit v1.2.3-24-g4f1b From d261b1e89c3d4d5191036d5a5660ef6764e593a0 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:12:16 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/libraries --- system/libraries/Log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Log.php') diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 51ce43dc7..baac80121 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -94,7 +94,7 @@ class CI_Log { { $config =& get_config(); - $this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/'; + $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path)) { @@ -111,7 +111,7 @@ class CI_Log { $this->_threshold_array = array_flip($config['log_threshold']); } - if ($config['log_date_format'] != '') + if ($config['log_date_format'] !== '') { $this->_date_fmt = $config['log_date_format']; } -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/libraries/Log.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'system/libraries/Log.php') diff --git a/system/libraries/Log.php b/system/libraries/Log.php index baac80121..a4dd47f86 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -1,4 +1,4 @@ -\n\n"; + $message .= '<'."?php if defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; } if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) -- cgit v1.2.3-24-g4f1b From fc2fbc55fbb234b842d9e9462e766211588d4880 Mon Sep 17 00:00:00 2001 From: Razican Date: Sat, 3 Nov 2012 13:52:34 +0100 Subject: Fixed typo in logs. --- system/libraries/Log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Log.php') diff --git a/system/libraries/Log.php b/system/libraries/Log.php index a4dd47f86..e66270840 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -152,7 +152,7 @@ class CI_Log { if ( ! file_exists($filepath)) { $newfile = TRUE; - $message .= '<'."?php if defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; + $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; } if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) -- cgit v1.2.3-24-g4f1b From 0aeee85b5164e31e2a76c05caa97bd898c1a776d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Nov 2012 17:43:11 +0200 Subject: Move the Log class to system/core/ It is a core class after all, I guess somebody forgot it when the rest of them were moved. --- system/libraries/Log.php | 181 ----------------------------------------------- 1 file changed, 181 deletions(-) delete mode 100644 system/libraries/Log.php (limited to 'system/libraries/Log.php') diff --git a/system/libraries/Log.php b/system/libraries/Log.php deleted file mode 100644 index e66270840..000000000 --- a/system/libraries/Log.php +++ /dev/null @@ -1,181 +0,0 @@ - 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4); - - /** - * Initialize Logging class - * - * @return void - */ - public function __construct() - { - $config =& get_config(); - - $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; - - if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path)) - { - $this->_enabled = FALSE; - } - - if (is_numeric($config['log_threshold'])) - { - $this->_threshold = (int) $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'] !== '') - { - $this->_date_fmt = $config['log_date_format']; - } - } - - // -------------------------------------------------------------------- - - /** - * Write Log File - * - * Generally this function will be called using the global log_message() function - * - * @param string the error level - * @param string the error message - * @param bool whether the error is a native PHP error - * @return bool - */ - public function write_log($level = 'error', $msg, $php_error = FALSE) - { - if ($this->_enabled === FALSE) - { - return FALSE; - } - - $level = strtoupper($level); - - if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold)) - && ! isset($this->_threshold_array[$this->_levels[$level]])) - { - return FALSE; - } - - - $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php'; - $message = ''; - - if ( ! file_exists($filepath)) - { - $newfile = TRUE; - $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; - } - - if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) - { - return FALSE; - } - - $message .= $level.' '.($level === 'INFO' ? ' -' : '-').' '.date($this->_date_fmt).' --> '.$msg."\n"; - - flock($fp, LOCK_EX); - fwrite($fp, $message); - flock($fp, LOCK_UN); - fclose($fp); - - if (isset($newfile) && $newfile === TRUE) - { - @chmod($filepath, FILE_WRITE_MODE); - } - - return TRUE; - } - -} - -/* End of file Log.php */ -/* Location: ./system/libraries/Log.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b