Skip to content

Commit 06482f5

Browse files
committedJan 22, 2019
Rename sourceDir to rootDir
1 parent a696245 commit 06482f5

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ register_shutdown_function(function () use ($bufferedGraveyard) {
7171
### Relative Path Logs
7272

7373
By default the absolute file path is used in the logs. This can be in problem in some environments (e.g. when your
74-
deployment process creates a new directory for every release). If you tell the source root to the graveyard, it will log
74+
deployment process creates a new directory for every release). If you tell the root path to the graveyard, it will log
7575
the relative file path instead. This makes log files exchangeable between different servers/environments/installation
7676
paths.
7777

7878
```php
79-
GraveyardProvider::getGraveyard()->setSourceDir('/path/to/src');
79+
GraveyardProvider::getGraveyard()->setRootDir('/path/to/src');
8080
```
8181

8282
It is especially useful, if you want to collect logs files from multiple production servers to run an overall analysis

‎src/Graveyard.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ class Graveyard implements GraveyardInterface
2121
/**
2222
* @var string
2323
*/
24-
private $sourceDir;
24+
private $rootDir;
2525

2626
/**
2727
* @var int|null
2828
*/
2929
private $stackTraceDepth;
3030

31-
public function __construct(array $handlers = [], ?string $sourceDir = null, ?int $stackTraceDepth = null)
31+
public function __construct(array $handlers = [], ?string $rootDir = null, ?int $stackTraceDepth = null)
3232
{
3333
$this->handlers = $handlers;
3434
$this->traceProvider = new TraceProvider();
3535
$this->stackTraceDepth = $stackTraceDepth;
36-
$this->setSourceDir($sourceDir);
36+
$this->setRootDir($rootDir);
3737
}
3838

39-
public function setSourceDir($sourceDir): void
39+
public function setRootDir($rootDir): void
4040
{
41-
$this->sourceDir = $sourceDir;
41+
$this->rootDir = $rootDir;
4242
}
4343

4444
public function addHandler(HandlerInterface $handler): void
@@ -58,13 +58,13 @@ public function tombstone(array $arguments, array $trace, array $metadata): void
5858

5959
private function traceRelativePath(array $trace): array
6060
{
61-
if (!$this->sourceDir) {
61+
if (!$this->rootDir) {
6262
return $trace;
6363
}
6464

6565
foreach ($trace as $key => &$frame) {
6666
if (isset($frame['file'])) {
67-
$frame['file'] = PathNormalizer::makeRelativeTo($frame['file'], $this->sourceDir);
67+
$frame['file'] = PathNormalizer::makeRelativeTo($frame['file'], $this->rootDir);
6868
}
6969
}
7070

‎tests/GraveyardTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function tombstone_handlersRegistered_callAllHandlers(): void
6767
/**
6868
* @test
6969
*/
70-
public function tombstone_sourceDirSet_logRelativePath(): void
70+
public function tombstone_rootDirSet_logRelativePath(): void
7171
{
7272
$this->handler
7373
->expects($this->once())
@@ -77,14 +77,14 @@ public function tombstone_sourceDirSet_logRelativePath(): void
7777
}));
7878

7979
$trace = TraceFixture::getTraceFixture();
80-
$this->graveyard->setSourceDir('/path/to');
80+
$this->graveyard->setRootDir('/path/to');
8181
$this->graveyard->tombstone(['label'], $trace, ['metaField' => 'metaValue']);
8282
}
8383

8484
/**
8585
* @test
8686
*/
87-
public function tombstone_sourceDirNotMatchedFilePath_logAbsolutePath(): void
87+
public function tombstone_rootDirNotMatchedFilePath_logAbsolutePath(): void
8888
{
8989
$this->handler
9090
->expects($this->once())
@@ -94,7 +94,7 @@ public function tombstone_sourceDirNotMatchedFilePath_logAbsolutePath(): void
9494
}));
9595

9696
$trace = TraceFixture::getTraceFixture();
97-
$this->graveyard->setSourceDir('/other/path');
97+
$this->graveyard->setRootDir('/other/path');
9898
$this->graveyard->tombstone(['label'], $trace, ['metaField' => 'metaValue']);
9999
}
100100

0 commit comments

Comments
 (0)
Please sign in to comment.