Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolate the log message also for logged exceptions #29951

Merged
merged 1 commit into from
Nov 29, 2021

Conversation

ChristophWurst
Copy link
Member

According to PSR-3 the log message can have placeholders that are
replaced from the context object. Our logger implementation did that for
all PSR-3 logger methods. The only exception was our custom logException.

Since PsrLoggerAdapter calls logException when an exception key is
present in the context object, log messages were no longer interpolated.

Tested with the following snippet

		try {
			throw new \InvalidArgumentException('henlo');
		} catch (\Throwable $e) {
			$logger->debug('oh {no}', [
				'no' => 'no',
				'exception' => $e,
			]);
		}

On master I get oh {no} in my log. With this patch it's oh no.

According to PSR-3 the log message can have placeholders that are
replaced from the context object. Our logger implementation did that for
all PSR-3 logger methods. The only exception was our custom `logException`.

Since PsrLoggerAdapter calls logException when an exception key is
present in the context object, log messages were no longer interpolated.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@ChristophWurst ChristophWurst added bug 3. to review Waiting for reviews labels Nov 29, 2021
@ChristophWurst ChristophWurst added this to the Nextcloud 24 milestone Nov 29, 2021
@ChristophWurst ChristophWurst self-assigned this Nov 29, 2021
@ChristophWurst ChristophWurst requested review from ArtificialOwl and icewind1991 and removed request for a team November 29, 2021 13:33
@ChristophWurst
Copy link
Member Author

/backport to stable23

@ChristophWurst
Copy link
Member Author

/backport to stable22

@ChristophWurst
Copy link
Member Author

/backport to stable21

Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

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

Fine by me also with backports, but 20 is EOL

@ChristophWurst
Copy link
Member Author

20 is EOL

TIL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants