예제 #1
0
 public function getQuery(IEvent $event)
 {
     $result = $event->getRaw("result");
     $rows = 0;
     if (is_array($result)) {
         $rows = count($result);
     }
     $memory = memory_get_peak_usage(true);
     $error = $event->getArr("error", []);
     $args = [];
     foreach ($event->getArr("args", []) as $arg) {
         if (is_array($arg) || is_object($arg)) {
             $args[] = json_encode($arg);
         } else {
             if ($arg === null) {
                 $args[] = 'null';
             } else {
                 if (is_bool($arg)) {
                     $args[] = $arg ? 'true' : 'false';
                 } else {
                     $args[] = '"' . $arg . '"';
                 }
             }
         }
     }
     $query = sprintf("%s:%s.%s(%s)", $event->getStr("keyspace"), $event->getStr("column_family"), $event->getStr("method"), implode(', ', $args));
     $this->_addStatement($query, $event->getFloat("execution_time", 0), $rows, $memory, idx($error, 'num', 0), idx($error, 'msg', ''), idx($error, 'num', 0) == 0);
 }
예제 #2
0
 public function log(IEvent $e)
 {
     $level = $e->getStr('level');
     if (Log::logLevelAllowed($level, $this->_logLevel)) {
         // "critical", "error", "warning", "info", "debug"
         switch ($level) {
             case LogLevel::EMERGENCY:
             case LogLevel::ALERT:
             case LogLevel::CRITICAL:
                 $level = 'critical';
                 break;
             case LogLevel::ERROR:
                 $level = 'error';
                 break;
             case LogLevel::WARNING:
                 $level = 'warning';
                 break;
             case LogLevel::DEBUG:
                 $level = 'debug';
                 break;
             case LogLevel::NOTICE:
             case LogLevel::INFO:
             default:
                 $level = 'info';
                 break;
         }
         $data = ['file' => $e->getStr('file'), 'line' => $e->getStr('line'), 'context' => $e->getArr('context')];
         if (CUBEX_CLI) {
             $data['cli_command'] = implode(' ', $_SERVER['argv']);
         }
         \Rollbar::report_message($e->getStr('message'), $level, $data);
     }
 }
 public function listenP(IEvent $event, $response)
 {
     $expect = $event->getInt("number", 0) === 1 ? 'singular' : 'plural';
     if ($event->getStr($expect) !== $response) {
         $this->addTranslation($event->getStr("singular"), $response);
         $this->addTranslation($event->getStr("plural"), $response);
     }
 }
예제 #4
0
 public function trackEnd(IEvent $event)
 {
     $name = $event->getStr("name", null);
     if ($name !== null) {
         $this->stopMeasure($name);
     }
 }
예제 #5
0
 public function getQuery(IEvent $event)
 {
     $result = $event->getRaw("result");
     $rows = 0;
     if ($result instanceof \mysqli_result) {
         $rows = $result->num_rows;
     }
     $memory = memory_get_peak_usage(true);
     $error = $event->getArr("error", []);
     $this->_addStatement($event->getStr("query"), $event->getFloat("execution_time", 0), $rows, $memory, idx($error, 'num', 0), idx($error, 'msg', ''), idx($error, 'num', 0) == 0);
 }
예제 #6
0
 public function catchLog(IEvent $event)
 {
     $this->_debugBar['messages']->addMessage($event->getStr("message"), $event->getStr("level"));
 }
예제 #7
0
 public function addAdditionalEvent(IEvent $event)
 {
     $this->addAdditional($event->getStr("key"), $event->getStr("value"));
 }