Skip to content

Commit df57621

Browse files
committed
Added optional timestamp to logs
1 parent 617ac4a commit df57621

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/Log/AbstractLog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
abstract class AbstractLog extends \Jaeger\Thrift\Log
77
{
8-
public function __construct(array $tags = [])
8+
public function __construct(array $tags = [], int $timestamp = 0)
99
{
10-
$this->timestamp = (int)round(microtime(true) * 1000000);
10+
$this->timestamp = $timestamp ?? (int)round(microtime(true) * 1000000);
1111
$this->fields = $tags;
1212
parent::__construct();
1313
}

src/Log/ErrorLog.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
class ErrorLog extends AbstractLog
77
{
8-
public function __construct(string $message, string $stack)
8+
public function __construct(string $message, string $stack, int $timestamp = 0)
99
{
1010
parent::__construct(
1111
[
1212
new EventTag('error'),
1313
new MessageTag($message),
1414
new StackTag($stack)
15-
]
15+
],
16+
$timestamp
1617
);
1718
}
1819
}

src/Log/UserLog.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
class UserLog extends AbstractLog
77
{
8-
public function __construct(string $level, string $message)
8+
public function __construct(string $level, string $message, int $timestamp = 0)
99
{
1010
parent::__construct(
1111
[
1212
new EventTag('log'),
1313
new LevelTag($level),
1414
new MessageTag($message),
15-
]
15+
],
16+
$timestamp
1617
);
1718
}
1819
}

0 commit comments

Comments
 (0)