Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/log/PhabricatorProtocolLog.php
Show All 18 Lines | final class PhabricatorProtocolLog | ||||
public function didEndSession() { | public function didEndSession() { | ||||
$this->setMode('_'); | $this->setMode('_'); | ||||
$this->buffer[] = pht('<End of Session>'); | $this->buffer[] = pht('<End of Session>'); | ||||
$this->flush(); | $this->flush(); | ||||
} | } | ||||
public function didWriteBytes($bytes) { | public function didWriteBytes($bytes) { | ||||
if (!strlen($bytes)) { | if (!phutil_nonempty_string($bytes)) { | ||||
return; | return; | ||||
} | } | ||||
$this->setMode('>'); | $this->setMode('>'); | ||||
$this->buffer[] = $bytes; | $this->buffer[] = $bytes; | ||||
} | } | ||||
public function didReadBytes($bytes) { | public function didReadBytes($bytes) { | ||||
if (!strlen($bytes)) { | if (!phutil_nonempty_string($bytes)) { | ||||
return; | return; | ||||
} | } | ||||
$this->setMode('<'); | $this->setMode('<'); | ||||
$this->buffer[] = $bytes; | $this->buffer[] = $bytes; | ||||
} | } | ||||
public function didReadFrame($frame) { | public function didReadFrame($frame) { | ||||
Show All 34 Lines | private function flush() { | ||||
$mode = $this->mode; | $mode = $this->mode; | ||||
$bytes = $this->buffer; | $bytes = $this->buffer; | ||||
$this->mode = null; | $this->mode = null; | ||||
$this->buffer = array(); | $this->buffer = array(); | ||||
$bytes = implode('', $bytes); | $bytes = implode('', $bytes); | ||||
if (strlen($bytes)) { | if (phutil_nonempty_string($bytes)) { | ||||
$this->writeBytes($mode, $bytes); | $this->writeBytes($mode, $bytes); | ||||
} | } | ||||
} | } | ||||
private function writeBytes($mode, $bytes) { | private function writeBytes($mode, $bytes) { | ||||
$header = $mode; | $header = $mode; | ||||
$len = strlen($bytes); | $len = strlen($bytes); | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0