Changeset 1898 for trunk/system/core/Log.php
- Timestamp:
- 02/01/2008 06:22:27 PM (10 months ago)
- Files:
-
- 1 modified
-
trunk/system/core/Log.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/core/Log.php
r1828 r1898 12 12 final class Log { 13 13 14 private static $log_directory; 15 14 16 private static $types = array(1 => 'error', 2 => 'debug', 3 => 'info'); 15 17 private static $messages = array(); 18 19 /** 20 * Set the the log directory. The log directory is determined by Kohana::setup. 21 * 22 * @param string full log directory path 23 * @return void 24 */ 25 public static function directory($directory) 26 { 27 if (self::$log_directory === NULL) 28 { 29 // Set the log directory if it has not already been set 30 self::$log_directory = $directory; 31 } 32 } 16 33 17 34 /** … … 38 55 public static function write() 39 56 { 40 $filename = Config::item('log.directory');57 // Set the log threshold 41 58 $threshold = Config::item('log.threshold'); 42 59 43 60 // Don't log if there is nothing to log to 44 if ($threshold < 1 OR count(self::$messages) == 0 OR $filename == FALSE) return;61 if ($threshold < 1 OR count(self::$messages) === 0) return; 45 62 46 // Make sure that the log directory is absolute47 $filename = (substr($filename, 0, 1) === '/') ? $filename : APPPATH.$filename;63 // Set the log filename 64 $filename = self::$log_directory.date('Y-m-d').'.log'.EXT; 48 65 49 // Find the realpath to the log directory 50 $filename = realpath($filename).'/'; 51 52 // Make sure the log directory is writable 53 if ( ! is_dir($filename) OR ! is_writable($filename)) 54 { 55 // Disable errors 56 $ER = error_reporting(0); 57 58 // Clear the buffer 59 ob_get_level() and ob_clean(); 60 61 // Enable errors 62 error_reporting($ER); 63 64 exit(Kohana::lang('core.cannot_write_log')); 65 } 66 67 // Attach the filename to the directory 68 $filename .= date('Y-m-d').'.log'.EXT; 69 66 // Compile the messages 70 67 $messages = ''; 71 72 // Get messages73 68 foreach(self::$messages as $type => $data) 74 69 {
