當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TestHandler::getRecords方法代碼示例

本文整理匯總了PHP中Monolog\Handler\TestHandler::getRecords方法的典型用法代碼示例。如果您正苦於以下問題:PHP TestHandler::getRecords方法的具體用法?PHP TestHandler::getRecords怎麽用?PHP TestHandler::getRecords使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Monolog\Handler\TestHandler的用法示例。


在下文中一共展示了TestHandler::getRecords方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getLoggerStrings

 /**
  * Get all the logger entries.
  *
  * @return array
  */
 public function getLoggerStrings()
 {
     $records = $this->testLogger->getRecords();
     $return = [];
     foreach ($records as $record) {
         $return[] = $record['message'];
     }
     return $return;
 }
開發者ID:bairwell,項目名稱:middleware-cors,代碼行數:14,代碼來源:SlimTest.php

示例2: testNon2XXResponsesGetLoggedAsWarning

 public function testNon2XXResponsesGetLoggedAsWarning()
 {
     $testHandler = new TestHandler();
     $logger = new Logger('test', [$testHandler]);
     $response = $this->performTestRequest($logger, new Request('GET', 'http://example.com'), new Response(300));
     $this->assertEquals(300, $response->getStatusCode());
     $this->assertCount(2, $testHandler->getRecords());
     $this->assertEquals('HTTP response 300', $testHandler->getRecords()[1]['message']);
     $this->assertEquals('WARNING', $testHandler->getRecords()[1]['level_name']);
 }
開發者ID:jberkel,項目名稱:tool,代碼行數:10,代碼來源:LoggingMiddlewareTest.php

示例3: testHandleError

 public function testHandleError()
 {
     $logger = new Logger('test', array($handler = new TestHandler()));
     $errHandler = new ErrorHandler($logger);
     $errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false);
     trigger_error('Foo', E_USER_ERROR);
     $this->assertCount(1, $handler->getRecords());
     $this->assertTrue($handler->hasErrorRecords());
     trigger_error('Foo', E_USER_NOTICE);
     $this->assertCount(2, $handler->getRecords());
     $this->assertTrue($handler->hasEmergencyRecords());
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:12,代碼來源:ErrorHandlerTest.php

示例4: testHandler

 /**
  * @dataProvider methodProvider
  */
 public function testHandler($method, $level)
 {
     $handler = new TestHandler();
     $record = $this->getRecord($level, 'test' . $method);
     $this->assertFalse($handler->{'has' . $method}($record), 'has' . $method);
     $this->assertFalse($handler->{'has' . $method . 'ThatContains'}('test'), 'has' . $method . 'ThatContains');
     $this->assertFalse($handler->{'has' . $method . 'ThatPasses'}(function ($rec) {
         return true;
     }), 'has' . $method . 'ThatPasses');
     $this->assertFalse($handler->{'has' . $method . 'ThatMatches'}('/test\\w+/'));
     $this->assertFalse($handler->{'has' . $method . 'Records'}(), 'has' . $method . 'Records');
     $handler->handle($record);
     $this->assertFalse($handler->{'has' . $method}('bar'), 'has' . $method);
     $this->assertTrue($handler->{'has' . $method}($record), 'has' . $method);
     $this->assertTrue($handler->{'has' . $method}('test' . $method), 'has' . $method);
     $this->assertTrue($handler->{'has' . $method . 'ThatContains'}('test'), 'has' . $method . 'ThatContains');
     $this->assertTrue($handler->{'has' . $method . 'ThatPasses'}(function ($rec) {
         return true;
     }), 'has' . $method . 'ThatPasses');
     $this->assertTrue($handler->{'has' . $method . 'ThatMatches'}('/test\\w+/'));
     $this->assertTrue($handler->{'has' . $method . 'Records'}(), 'has' . $method . 'Records');
     $records = $handler->getRecords();
     unset($records[0]['formatted']);
     $this->assertEquals(array($record), $records);
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:28,代碼來源:TestHandlerTest.php

示例5: testProcessRecord

 /**
  * @covers Monolog\Handler\AbstractProcessingHandler::processRecord
  */
 public function testProcessRecord()
 {
     $handler = new TestHandler();
     $handler->pushProcessor(new WebProcessor(array('REQUEST_URI' => '', 'REQUEST_METHOD' => '', 'REMOTE_ADDR' => '')));
     $handler->handle($this->getRecord());
     list($record) = $handler->getRecords();
     $this->assertEquals(3, count($record['extra']));
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:11,代碼來源:AbstractProcessingHandlerTest.php

示例6: testExpiration

 public function testExpiration()
 {
     $startTime = microtime(true);
     $this->manager->aquire("my_key");
     $duration = microtime(true) - $startTime;
     $this->assertTrue($duration < 2);
     $loggerRecordList = $this->loggerTestHandler->getRecords();
     $this->assertEquals(0, count($loggerRecordList));
     $this->manager->aquire("my_key");
     $duration2 = microtime(true) - $startTime;
     $this->assertTrue($duration2 > 4);
     $loggerRecordList = $this->loggerTestHandler->getRecords();
     $this->assertEquals(1, count($loggerRecordList));
     $record = $loggerRecordList[0];
     $message = $record["message"];
     $this->assertEquals(1, preg_match('/Dead lock detected.+\\/Tests\\/Manager\\/ManagerTest\\.php\\(\\d+\\)/', $message));
 }
開發者ID:sepikas-antanas,項目名稱:KitpagesSemaphoreBundle,代碼行數:17,代碼來源:ManagerTest.php

示例7: outputLog

 protected function outputLog()
 {
     if ($this->option('debug')) {
         $this->info('Log:');
         foreach ($this->logHandler->getRecords() as $record) {
             $this->line(str_replace(PHP_EOL, '', $record['formatted']));
         }
     }
 }
開發者ID:shift31,項目名稱:haproxy-cluster-control,代碼行數:9,代碼來源:BaseCommand.php

示例8: testKernelException

 public function testKernelException()
 {
     $request = Request::create('/syrup/run', 'POST');
     $request->headers->set('X-StorageApi-Token', SYRUP_SAPI_TEST_TOKEN);
     $message = uniqid();
     $event = new GetResponseForExceptionEvent(self::$kernel, $request, HttpKernelInterface::MASTER_REQUEST, new UserException($message));
     $this->listener->onKernelException($event);
     $records = $this->testLogHandler->getRecords();
     $this->assertCount(1, $records);
     $record = array_pop($records);
     $this->assertArrayHasKey('priority', $record);
     $this->assertEquals('ERROR', $record['priority']);
     $this->assertArrayHasKey('exception', $record);
     $this->assertArrayHasKey('class', $record['exception']);
     $this->assertEquals('Keboola\\Syrup\\Exception\\UserException', $record['exception']['class']);
     $response = $event->getResponse();
     $this->assertEquals(400, $response->getStatusCode());
     $jsonResponse = json_decode($response->getContent(), true);
     $this->assertArrayHasKey('status', $jsonResponse);
     $this->assertEquals('error', $jsonResponse['status']);
     $this->assertArrayHasKey('code', $jsonResponse);
     $this->assertEquals(400, $jsonResponse['code']);
     $this->assertArrayHasKey('exceptionId', $jsonResponse);
     $this->assertArrayHasKey('runId', $jsonResponse);
     $message = uniqid();
     $event = new GetResponseForExceptionEvent(self::$kernel, $request, HttpKernelInterface::MASTER_REQUEST, new ClientException($message));
     $this->listener->onKernelException($event);
     $records = $this->testLogHandler->getRecords();
     $this->assertCount(2, $records);
     $record = array_pop($records);
     $this->assertArrayHasKey('priority', $record);
     $this->assertEquals('CRITICAL', $record['priority']);
     $this->assertArrayHasKey('exception', $record);
     $this->assertArrayHasKey('class', $record['exception']);
     $this->assertEquals('Keboola\\StorageApi\\ClientException', $record['exception']['class']);
     $response = $event->getResponse();
     $this->assertEquals(500, $response->getStatusCode());
     $jsonResponse = json_decode($response->getContent(), true);
     $this->assertArrayHasKey('status', $jsonResponse);
     $this->assertEquals('error', $jsonResponse['status']);
     $this->assertArrayHasKey('code', $jsonResponse);
     $this->assertEquals(500, $jsonResponse['code']);
     $this->assertArrayHasKey('exceptionId', $jsonResponse);
     $this->assertArrayHasKey('runId', $jsonResponse);
     $exception = new UserException(uniqid());
     $exception->setData(['d1' => uniqid(), 'd2' => uniqid()]);
     $event = new GetResponseForExceptionEvent(self::$kernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception);
     $this->listener->onKernelException($event);
     $records = $this->testLogHandler->getRecords();
     $this->assertCount(3, $records);
     $record = array_pop($records);
     $this->assertArrayHasKey('context', $record);
     $this->assertArrayHasKey('data', $record['context']);
     $this->assertArrayHasKey('d1', $record['context']['data']);
     $this->assertArrayHasKey('d2', $record['context']['data']);
 }
開發者ID:keboola,項目名稱:syrup,代碼行數:56,代碼來源:SyrupExceptionListenerTest.php

示例9: testWarn

 public function testWarn()
 {
     $context = array("foo" => "bar");
     Simple::warn("hello", $context);
     $this->assertTrue($this->handler->hasWarningRecords());
     foreach ($this->handler->getRecords() as $record) {
         $this->assertEquals("hello", $record['message']);
         $this->assertEquals("WARNING", $record['level_name']);
         $this->assertEquals($context, $record['context']);
     }
 }
開發者ID:centraldesktop,項目名稱:static-logger,代碼行數:11,代碼來源:SimpleTest.php

示例10: testHandleBuffers

 public function testHandleBuffers()
 {
     $test = new TestHandler();
     $handler = new BufferHandler($test);
     $handler->handle($this->getRecord(Logger::DEBUG));
     $handler->handle($this->getRecord(Logger::INFO));
     $this->assertFalse($test->hasDebugRecords());
     $this->assertFalse($test->hasInfoRecords());
     $handler->close();
     $this->assertTrue($test->hasInfoRecords());
     $this->assertTrue(count($test->getRecords()) === 2);
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:12,代碼來源:BufferHandlerTest.php

示例11: testHandle

 public function testHandle()
 {
     $testHandler = new TestHandler();
     $handler = new SamplingHandler($testHandler, 2);
     for ($i = 0; $i < 10000; $i++) {
         $handler->handle($this->getRecord());
     }
     $count = count($testHandler->getRecords());
     // $count should be half of 10k, so between 4k and 6k
     $this->assertLessThan(6000, $count);
     $this->assertGreaterThan(4000, $count);
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:12,代碼來源:SamplingHandlerTest.php

示例12: testHandleUsesProcessors

 /**
  * @covers Monolog\Handler\GroupHandler::handle
  */
 public function testHandleUsesProcessors()
 {
     $test = new TestHandler();
     $handler = new GroupHandler(array($test));
     $handler->pushProcessor(function ($record) {
         $record['extra']['foo'] = true;
         return $record;
     });
     $handler->handle($this->getRecord(Logger::WARNING));
     $this->assertTrue($test->hasWarningRecords());
     $records = $test->getRecords();
     $this->assertTrue($records[0]['extra']['foo']);
 }
開發者ID:Ceciceciceci,項目名稱:MySJSU-Class-Registration,代碼行數:16,代碼來源:GroupHandlerTest.php

示例13: testHandleBufferLimitWithFlushOnOverflow

 /**
  * @covers Monolog\Handler\BufferHandler::handle
  */
 public function testHandleBufferLimitWithFlushOnOverflow()
 {
     $test = new TestHandler();
     $handler = new BufferHandler($test, 3, Logger::DEBUG, true, true);
     // send two records
     $handler->handle($this->getRecord(Logger::DEBUG));
     $handler->handle($this->getRecord(Logger::DEBUG));
     $handler->handle($this->getRecord(Logger::DEBUG));
     $this->assertFalse($test->hasDebugRecords());
     $this->assertCount(0, $test->getRecords());
     // overflow
     $handler->handle($this->getRecord(Logger::INFO));
     $this->assertTrue($test->hasDebugRecords());
     $this->assertCount(3, $test->getRecords());
     // should buffer again
     $handler->handle($this->getRecord(Logger::WARNING));
     $this->assertCount(3, $test->getRecords());
     $handler->close();
     $this->assertCount(5, $test->getRecords());
     $this->assertTrue($test->hasWarningRecords());
     $this->assertTrue($test->hasInfoRecords());
 }
開發者ID:defra91,項目名稱:levecchiecredenze.it,代碼行數:25,代碼來源:BufferHandlerTest.php

示例14: testHandleWithCallback

 public function testHandleWithCallback()
 {
     $test = new TestHandler();
     $handler = new FingersCrossedHandler(function ($record, $handler) use($test) {
         return $test;
     });
     $handler->handle($this->getRecord(Logger::DEBUG));
     $handler->handle($this->getRecord(Logger::INFO));
     $this->assertFalse($test->hasDebugRecords());
     $this->assertFalse($test->hasInfoRecords());
     $handler->handle($this->getRecord(Logger::WARNING));
     $this->assertTrue($test->hasInfoRecords());
     $this->assertTrue(count($test->getRecords()) === 3);
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:14,代碼來源:FingersCrossedHandlerTest.php

示例15: testHandleAnother

 public function testHandleAnother()
 {
     $test = new TestHandler();
     $handler = new BubbleHandler($test, new \Bubble\CatchBubble(\Bubble\CatchBubble::TIMEOUT));
     $this->assertTrue($handler instanceof AbstractHandler);
     $debug = $this->getRecord(Logger::DEBUG, 'one message');
     $handler->handle($debug);
     $secondSame = $debug;
     $secondSame['message'] = 'another message';
     $secondSame['datetime'] = clone $debug['datetime'];
     $secondSame['datetime']->add(new \DateInterval('PT1S'));
     $handler->handle($secondSame);
     $this->assertCount(2, $test->getRecords());
 }
開發者ID:Magomogo,項目名稱:monolog-bubble,代碼行數:14,代碼來源:BubbleHandlerTest.php


注:本文中的Monolog\Handler\TestHandler::getRecords方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。