コード例 #1
0
ファイル: logserial.php プロジェクト: marcbredt/heili
<?php

namespace examples\logserial;

use core\AutoLoader;
use core\util\log\FileLogger;
use core\object\LoggableObject;
// load the autoloader manually after suffix expansion for files in
// the include path like 'Log.php'
require_once "../../core/autoloader.class.php";
$al = new AutoLoader(false, "../..");
$al->expand(".test.class.php,.interface.php,.php");
$al->load();
// create a filelogger for this example
$fl = new FileLogger("logserial.php");
$fl->logge("%", array($al));
$fl->logge("%", array($fl));
// create a loggable and serializeable object
class Foo extends LoggableObject
{
    private $foo = "bar";
    public function __construct()
    {
        $this->log("Message from %", array(__FILE__));
        $this->log("Message from %", array(__CLASS__), "DEBUG");
    }
}
$f = new Foo();
// the getFile function can be only called directly if LoggableObject's
// $logger is set via $f->logger->getFile()
// to avoid any problems when $f->logger===null the interface Loggable
コード例 #2
0
ファイル: timer.php プロジェクト: marcbredt/heili
namespace examples\shm;

use Exception;
use core\AutoLoader;
use core\util\log\FileLogger;
use core\control\Timer;
use core\shm\handler\SharedMemoryHandler;
// load the autoloader manually after suffix expansion for files in
// the include path like 'Log.php'
require_once "../../core/autoloader.class.php";
$al = new AutoLoader(false, "../..");
$al->expand(".test.class.php,.interface.php,.php");
$al->load();
// create a filelogger for this example
$fl = new FileLogger("shmhandler.php");
$fl->logge("%", array($al));
$fl->logge("%", array($fl));
// use a timer to control an action
$timeout = 2;
$tries = 3;
// set and start the timer
$timer = null;
if (strncmp(gettype($timeout), "integer", 7) == 0 && $timeout > 0) {
    $timer = new Timer($timeout);
}
if ($timer === null) {
    $fl->logge(__METHOD__ . ": %.", array(new TimerException("creation failed")));
    throw new TimerException("creation failed");
}
$timer->start();