4
* A @{class:PhutilChannelChannel} which wraps some other channel and writes
5
* data passed over it to a log file.
7
final class PhutilLogfileChannel extends PhutilChannelChannel {
11
public function setLogfile($path) {
12
$this->logfile = fopen($path, 'a');
13
$this->log('--- '.getmypid().' ---');
17
public function read() {
18
$buffer = parent::read();
19
$this->log('>>> '.phutil_loggable_string($buffer));
23
public function write($message) {
24
$this->log('<<< '.phutil_loggable_string($message));
25
return parent::write($message);
28
private function log($message) {
30
fwrite($this->logfile, $message."\n");