Skip to content

Conversation

@sasezaki
Copy link
Contributor

Introduces an optional placeholder interpolation feature that allows TestLogger to interpolate context values into message placeholders.
(e.g., "User {username} created" with context ['username' => 'bolivar']).
This makes it easier to test log messages with dynamic values.

I often want asserting placeholder interpolation message.

$this->assertTrue($logger->hasDebugThatContains('User bolivar created'));

Copy link
Member

@Jean85 Jean85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this behavior is in-spec for PSR-3...

@Seldaek
Copy link
Contributor

Seldaek commented Oct 27, 2025

@Jean85 how so?

Copy link
Member

@Jean85 Jean85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right @Seldaek, I re-read the spec and it specifically allows this use case:

The message MAY contain placeholders which implementors MAY replace with values from the context array.

@Seldaek Seldaek merged commit da1b3c0 into php-fig:main Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants