Skip to content

[DX] Attempt to improve logging messages with parameters #13418

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

Closed
wants to merge 4 commits into from
Closed

[DX] Attempt to improve logging messages with parameters #13418

wants to merge 4 commits into from

Conversation

linaori
Copy link
Contributor

@linaori linaori commented Jan 15, 2015

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #12594 (comment)
License MIT
Doc PR n/a

This PR is a follow-up of #12594 [DX] [HttpKernel] Use "context" argument when logging route in RouterListener.

I have attempted to improve the log messages, as well as updating the usage context. I wasn't sure if the log messages should end with a . or not, if so I can update all messages to confirm a standard.

@@ -67,7 +67,7 @@ public function handle(GetResponseEvent $event)
}

if (null !== $this->logger) {
$this->logger->info(sprintf('Basic Authentication Authorization header found for user "%s"', $username));
$this->logger->info(sprintf('Basic authentication Authorization header found for user "%s"', $username));
Copy link
Member

Choose a reason for hiding this comment

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

What about moving the username as well (same below.) The more static the message is, the better for log aggregators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure as in many cases the message would become borked. I agree that it would be a better solution.

Edit, I can leave the username in the message and add it to the context.

Copy link
Member

Choose a reason for hiding this comment

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

"Basic authentication Authorization header found" is enough I think.

@linaori
Copy link
Contributor Author

linaori commented Jan 15, 2015

@stof @fabpot I have processed the remarks. While at it, I want to add or remove the trailing .. In exceptions they are present, but not in all the logs. Should I remove them all or add them all? It might be a good idea to add it in this PR as no history will be lost of this change if someone decides to add them later.

@linaori
Copy link
Contributor Author

linaori commented Jan 15, 2015

Seems like a flaky test is making this build fail:

1) Symfony\Component\Process\Tests\SimpleProcessTest::testStopWithTimeoutIsActuallyWorking
Failed asserting that 4.0517840385437 is less than 4.

@fabpot
Copy link
Member

fabpot commented Jan 15, 2015

I would add dots everywhere (which is what we do for exception messages).

@linaori
Copy link
Contributor Author

linaori commented Jan 15, 2015

Dots added and tests updated.

@fabpot
Copy link
Member

fabpot commented Jan 16, 2015

👍

@fabpot
Copy link
Member

fabpot commented Jan 16, 2015

Thank you @iltar.

@fabpot fabpot closed this in da9d88d Jan 16, 2015
@linaori linaori deleted the dx/context-logging branch April 15, 2016 13:33
fabpot added a commit that referenced this pull request Sep 21, 2016
…n logging it. (Koc)

This PR was merged into the 2.7 branch.

Discussion
----------

[DX] Fixed regression when exception message swallowed when logging it.

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | maybe, wait for Travis
| Fixed tickets | fixed regression introduced in #13418
| License       | MIT
| Doc PR        | -

The problem is: after merging referenced PR we cann't understand what error occured and why authentication request failed (see attached screenshot). Previously it displays exception message, but now it only displays class of the exception.

![9003644109](https://cloud.githubusercontent.com/assets/191082/18717550/f0df61c4-8028-11e6-8dbb-684e4928e913.jpg)

Commits
-------

042cb6b Fixed regression when exception message swallowed when logging it.
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