コード例 #1
0
ファイル: Logger.php プロジェクト: reoring/sabel
 public static function create()
 {
     if (self::$instance === null) {
         self::$instance = new self();
         self::$instance->addLogger(new Sabel_Logger_File());
         register_shutdown_function(array(self::$instance, "output"));
     }
     return self::$instance;
 }
コード例 #2
0
ファイル: Bus.php プロジェクト: reoring/sabel
 public function run(Sabel_Bus_Config $config)
 {
     foreach ($config->getProcessors() as $name => $className) {
         $this->addProcessor(new $className($name));
     }
     foreach ($config->getConfigs() as $name => $className) {
         $this->setConfig($name, new $className());
     }
     $this->interfaces = $config->getInterfaces();
     $logging = $config->isLogging();
     try {
         $logger = Sabel_Logger::create();
         $processorList = $this->processorList;
         while ($processor = $processorList->next()) {
             $processorName = $processor->name;
             $beforeEvents = $this->beforeEvent;
             if (isset($beforeEvents[$processorName])) {
                 foreach ($beforeEvents[$processorName] as $event) {
                     if ($logging) {
                         $logger->write("Bus: beforeEvent " . $event->object->getName() . "::" . $event->method . "()");
                     }
                     $event->object->{$event->method}($this);
                 }
             }
             if ($logging) {
                 $logger->write("Bus: execute " . $processor->name);
             }
             $processor->execute($this);
             $afterEvents = $this->afterEvent;
             if (isset($afterEvents[$processorName])) {
                 foreach ($afterEvents[$processorName] as $event) {
                     if ($logging) {
                         $logger->write("Bus: afterEvent " . $event->object->getName() . "::" . $event->method . "()");
                     }
                     $event->object->{$event->method}($this);
                 }
             }
         }
         $processorList->first();
         while ($processor = $processorList->next()) {
             if ($logging) {
                 $logger->write("Bus: shutdown " . $processor->name);
             }
             $processor->shutdown($this);
         }
         return $this->get("result");
     } catch (Exception $e) {
         $message = get_class($e) . ": " . $e->getMessage();
         $logger->write($message);
         return (ENVIRONMENT & DEVELOPMENT) > 0 ? $message : "";
     }
 }
コード例 #3
0
ファイル: Functions.php プロジェクト: hamaco/phwittr-on-xoops
function l($message, $level = SBL_LOG_INFO, $identifier = "default")
{
    Sabel_Logger::create()->write($message, $level, $identifier);
}