Example #1
0
 public function testStaticGetLevelNameException()
 {
     $exception = $this->catchException(function () {
         CM_Log_Logger::getLevelName(666);
     });
     $this->assertInstanceOf('CM_Exception_Invalid', $exception);
     /** @var CM_Exception_Invalid $exception */
     $this->assertSame('Level is not defined', $exception->getMessage());
     $this->assertSame(['level' => 666, 'availableLevels' => '100, 200, 300, 400, 500'], $exception->getMetaInfo());
 }
Example #2
0
 /**
  * @param CM_Log_Record $record
  * @return array
  * @throws CM_Exception_Invalid
  */
 protected function _getRecordInfo(CM_Log_Record $record)
 {
     $computerInfo = $record->getContext()->getComputerInfo();
     return ['datetime' => $record->getCreatedAt()->format($this->_formatDate), 'levelname' => CM_Log_Logger::getLevelName($record->getLevel()), 'message' => $record->getMessage(), 'fqdn' => null === $computerInfo ? 'none' : $computerInfo->getFullyQualifiedDomainName(), 'phpVersion' => null === $computerInfo ? 'none' : $computerInfo->getPhpVersion()];
 }
Example #3
0
 public function testStaticLogLevelMethods()
 {
     $this->assertSame('INFO', CM_Log_Logger::getLevelName(CM_Log_Logger::INFO));
     $this->assertNotEmpty(CM_Log_Logger::getLevels());
     $this->assertTrue(CM_Log_Logger::hasLevel(CM_Log_Logger::INFO));
     $this->assertFalse(CM_Log_Logger::hasLevel(666));
 }