converted to unix-style eol
[www-register-wizard.git] / libraries / Log.php
index 811c873..326edaa 100644 (file)
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r
-/**\r
- * CodeIgniter\r
- *\r
- * An open source application development framework for PHP 4.3.2 or newer\r
- *\r
- * @package            CodeIgniter\r
- * @author             ExpressionEngine Dev Team\r
- * @copyright  Copyright (c) 2008, EllisLab, Inc.\r
- * @license            http://codeigniter.com/user_guide/license.html\r
- * @link               http://codeigniter.com\r
- * @since              Version 1.0\r
- * @filesource\r
- */\r
-\r
-// ------------------------------------------------------------------------\r
-\r
-/**\r
- * Logging Class\r
- *\r
- * @package            CodeIgniter\r
- * @subpackage Libraries\r
- * @category   Logging\r
- * @author             ExpressionEngine Dev Team\r
- * @link               http://codeigniter.com/user_guide/general/errors.html\r
- */\r
-class CI_Log {\r
-\r
-       var $log_path;\r
-       var $_threshold = 1;\r
-       var $_date_fmt  = 'Y-m-d H:i:s';\r
-       var $_enabled   = TRUE;\r
-       var $_levels    = array('ERROR' => '1', 'DEBUG' => '2',  'INFO' => '3', 'ALL' => '4');\r
-\r
-       /**\r
-        * Constructor\r
-        *\r
-        * @access      public\r
-        */\r
-       function CI_Log()\r
-       {\r
-               $config =& get_config();\r
-               \r
-               $this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'logs/';\r
-               \r
-               if ( ! is_dir($this->log_path) OR ! is_really_writable($this->log_path))\r
-               {\r
-                       $this->_enabled = FALSE;\r
-               }\r
-               \r
-               if (is_numeric($config['log_threshold']))\r
-               {\r
-                       $this->_threshold = $config['log_threshold'];\r
-               }\r
-                       \r
-               if ($config['log_date_format'] != '')\r
-               {\r
-                       $this->_date_fmt = $config['log_date_format'];\r
-               }\r
-       }\r
-       \r
-       // --------------------------------------------------------------------\r
-       \r
-       /**\r
-        * Write Log File\r
-        *\r
-        * Generally this function will be called using the global log_message() function\r
-        *\r
-        * @access      public\r
-        * @param       string  the error level\r
-        * @param       string  the error message\r
-        * @param       bool    whether the error is a native PHP error\r
-        * @return      bool\r
-        */             \r
-       function write_log($level = 'error', $msg, $php_error = FALSE)\r
-       {               \r
-               if ($this->_enabled === FALSE)\r
-               {\r
-                       return FALSE;\r
-               }\r
-       \r
-               $level = strtoupper($level);\r
-               \r
-               if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))\r
-               {\r
-                       return FALSE;\r
-               }\r
-       \r
-               $filepath = $this->log_path.'log-'.date('Y-m-d').EXT;\r
-               $message  = '';\r
-               \r
-               if ( ! file_exists($filepath))\r
-               {\r
-                       $message .= "<"."?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";\r
-               }\r
-                       \r
-               if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))\r
-               {\r
-                       return FALSE;\r
-               }\r
-\r
-               $message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n";\r
-               \r
-               flock($fp, LOCK_EX);    \r
-               fwrite($fp, $message);\r
-               flock($fp, LOCK_UN);\r
-               fclose($fp);\r
-       \r
-               @chmod($filepath, FILE_WRITE_MODE);             \r
-               return TRUE;\r
-       }\r
-\r
-}\r
-// END Log Class\r
-\r
-/* End of file Log.php */\r
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Logging Class
+ *
+ * @package            CodeIgniter
+ * @subpackage Libraries
+ * @category   Logging
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/general/errors.html
+ */
+class CI_Log {
+
+       var $log_path;
+       var $_threshold = 1;
+       var $_date_fmt  = 'Y-m-d H:i:s';
+       var $_enabled   = TRUE;
+       var $_levels    = array('ERROR' => '1', 'DEBUG' => '2',  'INFO' => '3', 'ALL' => '4');
+
+       /**
+        * Constructor
+        *
+        * @access      public
+        */
+       function CI_Log()
+       {
+               $config =& get_config();
+               
+               $this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'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 = $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
+        *
+        * @access      public
+        * @param       string  the error level
+        * @param       string  the error message
+        * @param       bool    whether the error is a native PHP error
+        * @return      bool
+        */             
+       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))
+               {
+                       return FALSE;
+               }
+       
+               $filepath = $this->log_path.'log-'.date('Y-m-d').EXT;
+               $message  = '';
+               
+               if ( ! file_exists($filepath))
+               {
+                       $message .= "<"."?php  if ( ! defined('BASEPATH')) 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);
+       
+               @chmod($filepath, FILE_WRITE_MODE);             
+               return TRUE;
+       }
+
+}
+// END Log Class
+
+/* End of file Log.php */
 /* Location: ./system/libraries/Log.php */
\ No newline at end of file