Skip to content

[RFC][DIC] Allow logging from extensions #48921

Closed
@kiler129

Description

@kiler129

Description

When building a new reusable bundle, it is useful to log what was automatically registered on the container based on the bundle semantic configuration. In compiler passes, it is possible with a simple $container->log(). However, the signature of log() prohibits passing anything which is not a CompilerPassInterface:

public function log(CompilerPassInterface $pass, string $message)
{
$this->getCompiler()->log($pass, $this->resolveEnvPlaceholders($message));

public function log(CompilerPassInterface $pass, string $message)
{
if (str_contains($message, "\n")) {
$message = str_replace("\n", "\n".$pass::class.': ', trim($message));
}
$this->log[] = $pass::class.': '.$message;

That change is very non-invasive, as it essentially boils down to adding |\Symfony\Component\DependencyInjection\Extension\ExtensionInterface on both log() methods. They're both marked as @final and are using the class only for the informational purposes. Since 6.2 requires PHP 8.1 and | is supported since 8.0 this shouldn't be a problem.

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)Stalled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions