fp = fopen($this->target, 'w'); if(is_resource($this->fp) && $this->layout !== null) { fwrite($this->fp, $this->layout->getHeader()); } $this->closed = (bool)is_resource($this->fp) === false; } public function close() { if($this->closed != true) { if (is_resource($this->fp) && $this->layout !== null) { fwrite($this->fp, $this->layout->getFooter()); fclose($this->fp); } $this->closed = true; } } public function append(LoggerLoggingEvent $event) { if (is_resource($this->fp) && $this->layout !== null) { fwrite($this->fp, $this->layout->format($event)); } } /** * Sets the 'target' parameter. * @param string $target */ public function setTarget($target) { $value = trim($target); if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') { $this->target = self::STDOUT; } elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') { $this->target = self::STDERR; } else { $target = var_export($target); $this->warn("Invalid value given for 'target' property: [$target]. Property not set."); } } /** * Returns the value of the 'target' parameter. * @return string */ public function getTarget() { return $this->target; } }