/**
  * 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;
         }
     }
     //$this->rollOver();
     //var_dump($this);
     //parent::append($event);
     $this->write($this->layout->getFooter());
 }
 /**
  * Converts the logging event into an array which can be logged to mongodb.
  * 
  * @param LoggerLoggingEvent $event
  * @return array The array representation of the logging event.
  */
 protected function format(LoggerLoggingEvent $event)
 {
     $timestampSec = (int) $event->getTimestamp();
     $timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);
     $document = array('timestamp' => new MongoDate($timestampSec, $timestampUsec), 'level' => $event->getLevel()->toString(), 'thread' => (int) $event->getThreadName(), 'message' => $event->getMessage(), 'loggerName' => $event->getLoggerName());
     $locationInfo = $event->getLocationInformation();
     if ($locationInfo != null) {
         $document['fileName'] = $locationInfo->getFileName();
         $document['method'] = $locationInfo->getMethodName();
         $document['lineNumber'] = $locationInfo->getLineNumber() == 'NA' ? 'NA' : (int) $locationInfo->getLineNumber();
         $document['className'] = $locationInfo->getClassName();
     }
     $throwableInfo = $event->getThrowableInformation();
     if ($throwableInfo != null) {
         $document['exception'] = $this->formatThrowable($throwableInfo->getThrowable());
     }
     return $document;
 }