Example #1
0
 /**
  * This method processes the models and returns the status.
  *
  * @access public
  * @param BT\Exchange $exchange                             the exchange given to process
  * @return integer                                          the status code
  */
 public function process(BT\Exchange $exchange)
 {
     $status = BT\Task\Handler::process($this->task, $exchange);
     if ($this->isEnabled()) {
         switch ($status) {
             case BT\Task\Status::INACTIVE:
                 $this->logger->add($this->level, 'Task: :task Status: Inactive', array(':task' => $this->task));
                 break;
             case BT\Task\Status::ACTIVE:
                 $this->logger->add($this->level, 'Task: :task Status: Active', array(':task' => $this->task));
                 break;
             case BT\Task\Status::SUCCESS:
                 $this->logger->add($this->level, 'Task: :task Status: Success', array(':task' => $this->task));
                 break;
             case BT\Task\Status::FAILED:
                 $this->logger->add($this->level, 'Task: :task Status: Failed', array(':task' => $this->task));
                 break;
             case BT\Task\Status::ERROR:
                 $this->logger->add($this->level, 'Task: :task Status: Error', array(':task' => $this->task));
                 break;
             case BT\Task\Status::QUIT:
                 $this->logger->add($this->level, 'Task: :task Status: Quit', array(':task' => $this->task));
                 break;
         }
     }
     return $status;
 }
Example #2
0
 /**
  * This method logs the specified message with an arbitrary level.
  *
  * @access public
  * @param mixed $level                                      the log level assigned to the message
  * @param string $message                                   the message to be logged
  * @param array $context                                    the values to replace in the message
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     if (is_string($level)) {
         $level = strtolower($level);
         Log\Manager::instance()->add(Log\Level::$level(), $message, $context);
     } else {
         Log\Manager::instance()->add($level, $message, $context);
     }
 }