Skip to content

Commit

Permalink
Fix LazyTracyLogger containing itself
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed May 30, 2019
1 parent 1d67c9d commit b2461ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/DI/MonologExtension.php
Expand Up @@ -148,6 +148,7 @@ public function afterCompile(ClassType $class): void
$initialize = $class->getMethod('initialize');

if (class_exists(Debugger::class) && $config['hook']['fromTracy'] && $builder->hasDefinition('tracy.logger')) {
$initialize->addBody('$this->getService("tracy.logger");'); // Create original Tracy\Logger service to prevent psrToTracyLazyAdapter contain itself - workaround for Tracy\ILogger service created statically
$initialize->addBody($builder->formatPhp(Debugger::class . '::setLogger(?);', [$this->prefix('@psrToTracyLazyAdapter')]));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/DI/MonologExtensionTest.php
Expand Up @@ -23,7 +23,7 @@ public function testRegistration(): void
{
$container = $this->createContainer(__DIR__ . '/config.neon');

// Needed for LoggerHolder
// Needed for LoggerHolder and creation of original Tracy\Logger
$container->initialize();

/** @var Logger $default */
Expand Down

0 comments on commit b2461ce

Please sign in to comment.