Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93679745
PhutilLogfileChannel.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 30, 16:12
Size
750 B
Mime Type
text/x-php
Expires
Mon, Dec 2, 16:12 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22687831
Attached To
rPHU libphutil
PhutilLogfileChannel.php
View Options
<?php
/**
* A @{class:PhutilChannelChannel} which wraps some other channel and writes
* data passed over it to a log file.
*/
final
class
PhutilLogfileChannel
extends
PhutilChannelChannel
{
private
$logfile
;
public
function
setLogfile
(
$path
)
{
$this
->
logfile
=
fopen
(
$path
,
'a'
);
$this
->
log
(
'--- '
.
getmypid
().
' ---'
);
return
$this
;
}
public
function
read
()
{
$buffer
=
parent
::
read
();
$this
->
log
(
'>>> '
.
phutil_loggable_string
(
$buffer
));
return
$buffer
;
}
public
function
write
(
$message
)
{
$this
->
log
(
'<<< '
.
phutil_loggable_string
(
$message
));
return
parent
::
write
(
$message
);
}
private
function
log
(
$message
)
{
if
(
$this
->
logfile
)
{
fwrite
(
$this
->
logfile
,
$message
.
"
\n
"
);
}
}
}
Event Timeline
Log In to Comment