Exemplo n.º 1
0
 public function ajax_flushLog(CM_Params $params, CM_Frontend_JavascriptContainer $handler, CM_Http_Response_View_Ajax $response)
 {
     if (!$this->_getAllowedFlush($response->getRender()->getEnvironment())) {
         throw new CM_Exception_NotAllowed();
     }
     $level = $params->has('level') ? $params->getInt('level') : null;
     $levelList = $level ? [$level] : null;
     $type = $params->has('type') ? $params->getInt('type') : null;
     $logList = new CM_Paging_Log($levelList, $type);
     $logList->flush();
     $response->reloadComponent();
 }
Exemplo n.º 2
0
 public function testFlush()
 {
     $client = $this->getServiceManager()->getMongoDb();
     $encoder = new CM_Log_Encoder_MongoDb();
     $handler = new CM_Log_Handler_MongoDb($client, $encoder, CM_Paging_Log::COLLECTION_NAME);
     $context1 = new CM_Log_Context();
     $context1->setExtra(['bar' => 'quux']);
     $record1 = new CM_Log_Record(CM_Log_Logger::INFO, 'foo', $context1);
     $record2 = new CM_Log_Record(CM_Log_Logger::INFO, 'baz', new CM_Log_Context());
     $record3 = new CM_Log_Record(CM_Log_Logger::CRITICAL, 'quux', new CM_Log_Context());
     $contextTyped = new CM_Log_Context();
     $contextTyped->setExtra(['type' => 1]);
     $typedRecord = new CM_Log_Record(CM_Log_Logger::INFO, 'baz', $contextTyped);
     $paging = new CM_Paging_Log([CM_Log_Logger::INFO, CM_Log_Logger::CRITICAL]);
     $this->assertSame(0, $paging->getCount());
     $handler->handleRecord($record1);
     $handler->handleRecord($record2);
     $handler->handleRecord($record3);
     $handler->handleRecord($typedRecord);
     $paging->_change();
     $this->assertSame(4, $paging->getCount());
     $paging->flush();
     $this->assertSame(0, $paging->getCount());
 }