| [ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * This file is part of the symfony package. 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 /** 12 * 13 * @package symfony 14 * @subpackage log 15 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 16 * @version SVN: $Id: sfFileLogger.class.php 3329 2007-01-23 08:29:34Z fabien $ 17 */ 18 class sfFileLogger 19 { 20 protected 21 $fp = null; 22 23 /** 24 * Initializes the file logger. 25 * 26 * @param array Options for the logger 27 */ 28 public function initialize($options = array()) 29 { 30 if (!isset($options['file'])) 31 { 32 throw new sfConfigurationException('File option is mandatory for a file logger'); 33 } 34 35 $dir = dirname($options['file']); 36 37 if (!is_dir($dir)) 38 { 39 mkdir($dir, 0777, 1); 40 } 41 42 if (!is_writable($dir) || (file_exists($options['file']) && !is_writable($options['file']))) 43 { 44 throw new sfFileException(sprintf('Unable to open the log file "%s" for writing', $options['file'])); 45 } 46 47 $this->fp = fopen($options['file'], 'a'); 48 } 49 50 /** 51 * Logs a message. 52 * 53 * @param string Message 54 * @param string Message priority 55 * @param string Message priority name 56 */ 57 public function log($message, $priority, $priorityName) 58 { 59 $line = sprintf("%s %s [%s] %s%s", strftime('%b %d %H:%M:%S'), 'symfony', $priorityName, $message, DIRECTORY_SEPARATOR == '\\' ? "\r\n" : "\n"); 60 61 flock($this->fp, LOCK_EX); 62 fwrite($this->fp, $line); 63 flock($this->fp, LOCK_UN); 64 } 65 66 /** 67 * Executes the shutdown method. 68 */ 69 public function shutdown() 70 { 71 if ($this->fp) 72 { 73 fclose($this->fp); 74 } 75 } 76 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |