Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3281843
PhutilLogFileChannel.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
824 B
Referenced Files
None
Subscribers
None
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
(
)
;
if
(
strlen
(
$buffer
)
)
{
$this
->
log
(
'>>> '
.
phutil_loggable_string
(
$buffer
)
)
;
}
return
$buffer
;
}
public
function
write
(
$message
)
{
if
(
strlen
(
$message
)
)
{
$this
->
log
(
'<<< '
.
phutil_loggable_string
(
$message
)
)
;
}
return
parent
::
write
(
$message
)
;
}
private
function
log
(
$message
)
{
if
(
$this
->
logfile
)
{
fwrite
(
$this
->
logfile
,
$message
.
"\n"
)
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Mar 24, 01:56 (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1114941
Default Alt Text
PhutilLogFileChannel.php (824 B)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment