[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorConduitLogController 4 extends PhabricatorConduitController { 5 6 public function processRequest() { 7 $request = $this->getRequest(); 8 $viewer = $request->getUser(); 9 10 $conn_table = new PhabricatorConduitConnectionLog(); 11 $call_table = new PhabricatorConduitMethodCallLog(); 12 13 $conn_r = $call_table->establishConnection('r'); 14 15 $pager = new AphrontCursorPagerView(); 16 $pager->readFromRequest($request); 17 $pager->setPageSize(500); 18 19 $query = id(new PhabricatorConduitLogQuery()) 20 ->setViewer($viewer); 21 22 $methods = $request->getStrList('methods'); 23 if ($methods) { 24 $query->withMethods($methods); 25 } 26 27 $calls = $query->executeWithCursorPager($pager); 28 29 $conn_ids = array_filter(mpull($calls, 'getConnectionID')); 30 $conns = array(); 31 if ($conn_ids) { 32 $conns = $conn_table->loadAllWhere( 33 'id IN (%Ld)', 34 $conn_ids); 35 } 36 37 $table = $this->renderCallTable($calls, $conns); 38 39 $crumbs = $this->buildApplicationCrumbs(); 40 $crumbs->addTextCrumb(pht('Call Logs')); 41 42 return $this->buildApplicationPage( 43 array( 44 $crumbs, 45 $table, 46 $pager, 47 ), 48 array( 49 'title' => 'Conduit Logs', 50 )); 51 } 52 53 private function renderCallTable(array $calls, array $conns) { 54 assert_instances_of($calls, 'PhabricatorConduitMethodCallLog'); 55 assert_instances_of($conns, 'PhabricatorConduitConnectionLog'); 56 57 $viewer = $this->getRequest()->getUser(); 58 59 $methods = id(new PhabricatorConduitMethodQuery()) 60 ->setViewer($viewer) 61 ->execute(); 62 $methods = mpull($methods, null, 'getAPIMethodName'); 63 64 $rows = array(); 65 foreach ($calls as $call) { 66 $conn = idx($conns, $call->getConnectionID()); 67 if ($conn) { 68 $name = $conn->getUserName(); 69 $client = ' (via '.$conn->getClient().')'; 70 } else { 71 $name = null; 72 $client = null; 73 } 74 75 $method = idx($methods, $call->getMethod()); 76 if ($method) { 77 switch ($method->getMethodStatus()) { 78 case ConduitAPIMethod::METHOD_STATUS_STABLE: 79 $status = null; 80 break; 81 case ConduitAPIMethod::METHOD_STATUS_UNSTABLE: 82 $status = pht('Unstable'); 83 break; 84 case ConduitAPIMethod::METHOD_STATUS_DEPRECATED: 85 $status = pht('Deprecated'); 86 break; 87 } 88 } else { 89 $status = pht('Unknown'); 90 } 91 92 $rows[] = array( 93 $call->getConnectionID(), 94 $name, 95 array($call->getMethod(), $client), 96 $status, 97 $call->getError(), 98 number_format($call->getDuration()).' us', 99 phabricator_datetime($call->getDateCreated(), $viewer), 100 ); 101 } 102 103 $table = id(new AphrontTableView($rows)) 104 ->setDeviceReadyTable(true); 105 106 $table->setHeaders( 107 array( 108 'Connection', 109 'User', 110 'Method', 111 'Status', 112 'Error', 113 'Duration', 114 'Date', 115 )); 116 $table->setColumnClasses( 117 array( 118 '', 119 '', 120 'wide', 121 '', 122 '', 123 'n', 124 'right', 125 )); 126 return $table; 127 } 128 129 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |