log() public method

Log a message.
public log ( mixed $level, string $message, array $context = [] ) : null | void
$level mixed
$message string
$context array
return null | void
示例#1
0
 public function testGetLastMessage2()
 {
     $client = new Client(array('log' => true));
     $log = new Log($client);
     // Set log path temp path as otherwise test fails with output
     $errorLog = ini_get('error_log');
     ini_set('error_log', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php.log');
     $message = 'hello world';
     $log->log($message);
     ini_set('error_log', $errorLog);
     $this->assertEquals($message, $log->getLastMessage());
 }
 /**
  * @group unit
  */
 public function testGetLastMessage2()
 {
     $client = $this->_getClient(array('log' => true));
     $log = new Log($client);
     // Set log path temp path as otherwise test fails with output
     $errorLog = ini_get('error_log');
     ini_set('error_log', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php.log');
     $this->_context['error_message'] = $this->_message;
     $message = json_encode($this->_context);
     $log->log(LogLevel::DEBUG, $this->_message, $this->_context);
     ini_set('error_log', $errorLog);
     $this->assertEquals($message, $log->getLastMessage());
 }
示例#3
0
文件: Client.php 项目: kskod/Elastica
 /**
  * @param string|\Elastica\Request $message
  */
 protected function _log($message)
 {
     if ($this->getConfig('log')) {
         $log = new Log($this->getConfig('log'));
         $log->log($message);
     }
 }