示例#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
文件: Task.php 项目: a13k5and3r/Tman
 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
文件: Task.php 项目: phasty/tman
 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);
     }
 }