Esempio n. 1
0
 /**
  * @return array
  */
 public function jsonSerialize()
 {
     $logArray = ['action' => $this->getAction(), 'started_at' => $this->getRequestStartedAt()->format('c'), 'started_ms' => TimeHelper::convertDateTimeToMillitime($this->getRequestStartedAt()), 'total_time' => $this->getTotalTime(), 'code' => $this->getResponseCode(), 'severity' => $this->getSeverity(), 'caller_id' => $this->getCallerId(), 'caller_action' => $this->getCallerAction(), 'user_id' => $this->getUserId(), 'host' => $this->getHost(), 'ip' => $this->getIp(), 'request_info' => ['query_parameters' => $this->getHttpRequestInformation()->getQueryParameters(), 'headers' => $this->getHttpRequestInformation()->getHeaders(), 'url' => $this->getHttpRequestInformation()->getUrl(), 'method' => $this->getHttpRequestInformation()->getMethod(), 'body_parameters' => $this->getHttpRequestInformation()->getBodyParameters()], 'exceptions' => $this->getExceptions(), 'message' => $this->getAdditionalData(), 'request_id' => $this->getRequestId()->getId()];
     // Optional parameters
     if ($this->getDbCalls() !== null) {
         $logArray['db_calls'] = $this->getDbCalls();
     }
     if ($this->getDbTime() !== null) {
         $logArray['db_time'] = $this->getDbTime();
     }
     if ($this->hasLines()) {
         $logArray['lines'] = [];
         foreach ($this->getLines() as $line) {
             $logArray['lines'][] = [$line->getSeverity(), TimeHelper::convertDateTimeToMicrotime($line->getMicroTime()), $line->getMessage()];
         }
     }
     return $logArray;
 }
Esempio n. 2
0
 /**
  * Line constructor.
  * @param int $severity
  * @param string $message
  * @param \DateTime $microTime
  */
 public function __construct($severity = Expression\Severity::UNKOWN, $message = '', \DateTime $microTime = null)
 {
     $this->severity = $severity;
     $this->message = $message;
     $this->microTime = $microTime ? $microTime : TimeHelper::getMicrotime();
 }