Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class StreamLogger extends BaseLogger
00016 {
00017 private $stream = null;
00018
00019 public function __destruct()
00020 {
00021 try {
00022 $this->close();
00023 } catch (BaseException $e) {
00024
00025 }
00026 }
00027
00031 public static function create()
00032 {
00033 return new self;
00034 }
00035
00039 public function getOutputStream()
00040 {
00041 return $this->stream;
00042 }
00043
00047 public function setOutputStream(OutputStream $stream)
00048 {
00049 $this->stream = $stream;
00050
00051 return $this;
00052 }
00053
00057 public function flush()
00058 {
00059 if ($this->stream)
00060 $this->stream->flush();
00061
00062 return $this;
00063 }
00064
00068 public function close()
00069 {
00070 if ($this->stream) {
00071
00072 $this->flush();
00073 $this->stream->close();
00074
00075 $this->stream = null;
00076 }
00077
00078 return $this;
00079 }
00080
00084 protected function publish(LogRecord $record)
00085 {
00086 if (!$this->stream)
00087 return $this;
00088
00089 $this->stream->write($record->toString()."\n");
00090
00091 return $this;
00092 }
00093 }
00094 ?>