Пример #1
0
 public function __construct(Child\CallableClass $object)
 {
     $this->outStream = new \Phasty\Stream\Stream(STDOUT);
     $object->on(null, function ($event) {
         log::info("Event {$event->getName()} on object");
         $this->trigger($event);
     });
     $this->on(null, function ($event) {
         log::info("Event {$event->getName()} on process");
         $this->outStream->write($event);
     });
     $this->trigger("start", getmypid());
     $this->setHandlers();
 }
Пример #2
0
 protected function log($msg)
 {
     $error = false;
     if ($msg instanceof \Exception) {
         $msg = sprintf("Exception (%d) %s in %s:%d", $msg->getCode(), $msg->getMessage(), $msg->getFile(), $msg->getLine());
         $error = true;
     }
     if (!$this->canLog) {
         echo "{$msg}\n";
         return;
     }
     if ($this->verbose) {
         echo "{$msg}\n";
     }
     $error ? log::error($msg) : log::info($msg);
 }
Пример #3
0
 protected function logByType($msg, $type)
 {
     if (!$this->canLog) {
         echo "{$msg}\n";
         return;
     }
     if ($this->verbose) {
         echo "{$msg}\n";
     }
     switch ($type) {
         case 'error':
             log::error($msg);
             break;
         case 'debug':
             log::debug($msg);
             break;
         default:
             log::info($msg);
     }
 }