示例#1
0
 /**
  * Perform forced log data to file
  *
  * @param mixed $data
  * @return $this
  */
 public function log($data = null)
 {
     if ($data === null) {
         $data = $this->_data;
     } else {
         if (!is_array($data)) {
             $data = array($data);
         }
     }
     $data = $this->_filterDebugData($data);
     $data['__pid'] = getmypid();
     $this->_logger->logFile($data, \Zend_Log::DEBUG, $this->_logFileName);
     return $this;
 }
示例#2
0
 /**
  * Not Magento exception handling
  *
  * @param \Exception $exception
  * @param string $alternativeText
  * @param string $group
  * @return $this
  */
 public function addException(\Exception $exception, $alternativeText, $group = null)
 {
     $message = sprintf('Exception message: %s%sTrace: %s', $exception->getMessage(), "\n", $exception->getTraceAsString());
     $this->logger->logFile($message, \Zend_Log::DEBUG, Logger::LOGGER_EXCEPTION);
     $this->addMessage($this->messageFactory->create(MessageInterface::TYPE_ERROR, $alternativeText), $group);
     return $this;
 }
示例#3
0
 public function testLogFile()
 {
     $message = ['Wrong file name', 'Avoid using special chars'];
     $filename = 'custom_file.log';
     $this->model->logFile($message, \Zend_Log::DEBUG);
     $this->model->logFile($message, \Zend_Log::DEBUG, $filename);
     $this->assertTrue($this->model->hasLog($filename));
 }