note 74205 added to function.ob-start
| From: | traceyATarchiveDOTorg at osu1 dot php dot net | Date: | Thu, 29 Mar 2007 21:01:58 +0000 |
| Subject: | note 74205 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124931@lists.php.net to get a copy of this message | ||
Way to make all stdout and stderr write to a log
from *inside* a php script.
You simply need to make sure to call elog() every
once in awhile to get output.
It's a nice way to "daemonize" a script w.r.t. its logging.
// This allows us to capture all stdout and stderr (and error_log() calls)
// to this logfile...
// The "collected output" will be flushed anytime "elog()" is used...
ini_set("error_log", "/var/log/script.log");
ob_start();
function elog($str)
{
// get anything written to stdout or stderr that did *NOT* use elog()
// and write it now...
$writeme = ob_get_contents();
if ($writeme)
{
error_log($writeme);
ob_end_clean();
ob_start();
}
// now write message this method was called with
error_log($str);
}
----
Server IP: 64.71.164.2
Probable Submitter: 207.241.238.199
----
Manual Page -- http://www.php.net/manual/en/function.ob-start.php
Edit -- https://master.php.net/note/edit/74205
Del: integrated -- https://master.php.net/note/delete/74205/integrated
Del: useless -- https://master.php.net/note/delete/74205/useless
Del: bad code -- https://master.php.net/note/delete/74205/bad+code
Del: spam -- https://master.php.net/note/delete/74205/spam
Del: non-english -- https://master.php.net/note/delete/74205/non-english
Del: in docs -- https://master.php.net/note/delete/74205/in+docs
Del: other reasons-- https://master.php.net/note/delete/74205
Reject -- https://master.php.net/note/reject/74205
Search -- https://master.php.net/manage/user-notes.php