Figure 5: TailFile class checking for new errors in the PHP error log


#!/usr/local/Zend/Core/bin/php -q

<?

// check_php_log.php

// Display new errors that appear in Zend Core's error log

// Adapted from Matthew Frederico's tail-example.php

//

// First line gives default location of PHP executable in Zend Core for i5/OS

// $tailfile is set to default name of Zend Core's error log



/****************************/

/* Configuration parameters */

/****************************/

# File Locations



$tailfile               = "/usr/local/Zend/Core/logs/php_error_log";



# How many seconds delay between checks



$check_delay    = 5;



/**********************************************/

/*          M A I N   P R O G R A M           */

/**********************************************/

include("tailfile.phpc");       // PHP Tail class.



// This is where we watch our PHP error log for updates

//---------------------------------------------

$t = new TailFile($tailfile);

print "Watching PHP log... \n";



while ($t->isOpen())

{

        $t->checkUpdates();

        $myres = $t->getResults();



        if ($myres)

                print $myres;

        

        $t->wait($check_delay);

}

//---------------------------------------------