Skip to content

Commit

Permalink
bug fix time
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Kaviani committed May 13, 2019
1 parent 98f5c2a commit 0d1300a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/NDJson/NDJsonHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ class NDJsonHandler
private $depth;
private $output;

/**
* Use to Bug Fix for protobuf php extension !!!
* @var array
*/
private $jsonSerializerReplaceArray = [
"spanCount" => "span_count",
"transactionId" => "transaction_id",
"parentId" => "parent_id",
"traceId" => "trace_id",
"preContext" => "pre_context",
"postContext" => "post_context",
"libraryFrame" => "library_frame",
"contextLine" => "context_line",
"absPath" => "abs_path",
"statusCode" => "status_code",
"contentType" => "content_type",
"remoteAddress" => "remote_address",
"httpVersion" => "http_version",
"headersSent" => "headers_sent",
];

public function __construct($depth = 512)
{
if ($depth !== 512 && PHP_VERSION < 5.5) {
Expand Down Expand Up @@ -49,6 +70,11 @@ public function getOutput() {

$re = '/("timestamp":("(\d{16})"))/m';
$this->output = preg_replace($re, '"timestamp":$3',$this->output);

foreach ($this->jsonSerializerReplaceArray as $search => $replace) {
$this->output = str_replace($search,$replace,$this->output);
}

return $this->output;
}

Expand Down

0 comments on commit 0d1300a

Please sign in to comment.