Skip to content

Commit

Permalink
Returned tracy 2.7 support (#41)
Browse files Browse the repository at this point in the history
* Returned tracy 2.7 support

* Removed typehint to be compatible with Tracy\Logger

* Added test to access priority

* Changed test - level_name should be info

* Spaces > tabs
  • Loading branch information
mikoczy authored Oct 7, 2020
1 parent d971613 commit f0cea68
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"nette/di": "^3.0",
"kdyby/strict-objects": "^2.0",
"monolog/monolog": "^2.0",
"tracy/tracy": "^3.0"
"tracy/tracy": "^2.7 || ^3.0"
},
"require-dev": {
"nette/application": "^3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Tracy/BlueScreenRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function renderToFile($exception, $file): string
* @internal
* @deprecated
*/
public function log($message, string $priority = self::INFO): ?string
public function log($message, $priority = self::INFO): ?string
{
throw new \Kdyby\Monolog\Exception\NotSupportedException('This class is only for rendering exceptions');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tracy/MonologAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getExceptionFile(\Throwable $exception, string $level = self::EX
return $this->blueScreenRenderer->getExceptionFile($exception);
}

public function log($originalMessage, string $priority = self::INFO): ?string
public function log($originalMessage, $priority = self::INFO): ?string
{
$message = $this->formatMessage($originalMessage);
$context = [
Expand Down
13 changes: 13 additions & 0 deletions tests/KdybyTests/Monolog/MonologAdapterTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ class MonologAdapterTest extends \Tester\TestCase
Assert::match('CLI%a%: %a%/MonologAdapterTest.phpt%a%', $record['context']['at']);
}

public function testLogWithAccessPriority()
{
$this->adapter->log('test access message', MonologAdapter::ACCESS);
Assert::count(1, $this->testHandler->getRecords());

list($record) = $this->testHandler->getRecords();
Assert::same('kdyby', $record['channel']);
Assert::same('test access message', $record['message']);
Assert::same('INFO', $record['level_name']);
Assert::same(MonologAdapter::ACCESS, $record['context']['priority']);
Assert::match('CLI%a%: %a%/MonologAdapterTest.phpt%a%', $record['context']['at']);
}

}

(new MonologAdapterTest())->run();

0 comments on commit f0cea68

Please sign in to comment.