List Info

Thread: note 74205 added to function.ob-start




note 74205 added to function.ob-start
user name
2007-03-29 16:01:58
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 -- ht
tp://www.php.net/manual/en/function.ob-start.php
Edit        -- https://master
.php.net/note/edit/74205
Del: integrated  -- h
ttps://master.php.net/note/delete/74205/integrated
Del: useless     -- http
s://master.php.net/note/delete/74205/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/74205/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/74205
Reject      -- https://mast
er.php.net/note/reject/74205
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )