Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/log/PhabricatorProtocolLog.php
| Show All 35 Lines | public function didReadBytes($bytes) { | ||||
| if (!strlen($bytes)) { | if (!strlen($bytes)) { | ||||
| return; | return; | ||||
| } | } | ||||
| $this->setMode('<'); | $this->setMode('<'); | ||||
| $this->buffer[] = $bytes; | $this->buffer[] = $bytes; | ||||
| } | } | ||||
| public function didReadFrame($frame) { | |||||
| $this->writeFrame('<*', $frame); | |||||
| } | |||||
| public function didWriteFrame($frame) { | |||||
| $this->writeFrame('>*', $frame); | |||||
| } | |||||
| private function writeFrame($header, $frame) { | |||||
| $this->flush(); | |||||
| $frame = explode("\n", $frame); | |||||
| foreach ($frame as $key => $line) { | |||||
| $frame[$key] = $header.' '.$this->escapeBytes($line); | |||||
| } | |||||
| $frame = implode("\n", $frame)."\n\n"; | |||||
| $this->writeMessage($frame); | |||||
| } | |||||
| private function setMode($mode) { | private function setMode($mode) { | ||||
| if ($this->mode === $mode) { | if ($this->mode === $mode) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| if ($this->mode !== null) { | if ($this->mode !== null) { | ||||
| $this->flush(); | $this->flush(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines | |||||