public function testActivationDoesNotCreateTheFile()
 {
     $path = PHPUNIT_TEMP_DIR . "/doesnotexisthopefully.log";
     @unlink($path);
     $appender = new LoggerAppenderFile();
     $appender->setFile($path);
     $appender->activateOptions();
     self::assertFalse(file_exists($path));
     $event = LoggerTestHelper::getInfoEvent('bla');
     $appender->append($event);
     self::assertTrue(file_exists($path));
 }
 public function testSimpleLogging()
 {
     $layout = new LoggerLayoutSimple();
     $event = new LoggerLoggingEvent('LoggerAppenderFileTest', new Logger('mycategory'), LoggerLevel::getLevelWarn(), "my message");
     $appender = new LoggerAppenderFile("mylogger");
     $appender->setFileName('../../../target/temp/phpunit/TEST.txt');
     $appender->setLayout($layout);
     $appender->activateOptions();
     $appender->append($event);
     $appender->close();
     $v = file_get_contents('../../../target/temp/phpunit/TEST.txt');
     $e = "WARN - my message" . PHP_EOL;
     self::assertEquals($e, $v);
 }
 /**
  * @param LoggerLoggingEvent $event
  */
 public function append(LoggerLoggingEvent $event)
 {
     parent::append($event);
     if (ftell($this->fp) > $this->getMaximumFileSize()) {
         $this->rollOver();
     }
 }
 /**
  * @param LoggerLoggingEvent $event
  */
 function append($event)
 {
     if ($this->fp) {
         parent::append($event);
         if (ftell($this->fp) > $this->getMaximumFileSize()) {
             $this->rollOver();
         }
     }
 }
 /**
  * Appends a logging event.
  * 
  * If the target file changes because of passage of time (e.g. at midnight) 
  * the current file is closed. A new file, with the new date, will be 
  * opened by the write() method. 
  */
 public function append(LoggerLoggingEvent $event)
 {
     $eventDate = $this->getDate($event->getTimestamp());
     // Initial setting of current date
     if (!isset($this->currentDate)) {
         $this->currentDate = $eventDate;
     } else {
         if ($this->currentDate !== $eventDate) {
             $this->currentDate = $eventDate;
             // Close the file if it's open.
             // Note: $this->close() is not called here because it would set
             //       $this->closed to true and the appender would not recieve
             //       any more logging requests
             if (is_resource($this->fp)) {
                 $this->write($this->layout->getFooter());
                 fclose($this->fp);
             }
             $this->fp = null;
         }
     }
     parent::append($event);
 }