示例#1
0
 /**
  * Initializes the file logger.
  *
  * @param array Options for the logger
  */
 public function initialize($options = array())
 {
     if (!isset($options['file'])) {
         throw new sfConfigurationException('File option is mandatory for a file logger');
     }
     $dir = dirname($options['file']);
     if (!is_dir($dir)) {
         mkdir($dir, 0777, 1);
     }
     if (!is_writable($dir) || file_exists($options['file']) && !is_writable($options['file'])) {
         throw new sfFileException(sprintf('Unable to open the log file "%s" for writing', $options['file']));
     }
     $this->fp = fopen($options['file'], 'a');
     if (!self::$id) {
         self::$id = (string) (microtime(true) * 100);
     }
 }