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

Log the request path of a failed request in the ErrorMiddleware. #2170

Merged
merged 4 commits into from Feb 15, 2020

Conversation

maciejtrybilo
Copy link
Contributor

Added the request path to the logging from the ErrorMiddleware. For instance when a resource /hello/vapor cannot be found currently the log will read Abort.404: Not Found. After this change the log will read Abort.404: /hello/vapor Not Found which will improve monitoring.

@0xTim
Copy link
Member

0xTim commented Feb 7, 2020

@maciejtrybilo could you add a test to show the path being logged?

The only difference I can see is that this logs the path of every failed request, not just a 404. But I actually quite like that!

@maciejtrybilo
Copy link
Contributor Author

@0xTim Yep, that's why I've opened a separate PR as the functionality is a little different.

Added some tests. Let me know what you think!

@tanner0101 tanner0101 added the enhancement New feature or request label Feb 12, 2020
@tanner0101 tanner0101 added this to In Progress in Vapor 4 via automation Feb 12, 2020
@tanner0101 tanner0101 added this to In Progress in Vapor 3 via automation Feb 12, 2020
@tanner0101 tanner0101 removed this from In Progress in Vapor 4 Feb 12, 2020
Copy link
Member

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

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

+1 this approach is much better, thank you.

Sources/Vapor/Logging/Logger+LogError.swift Outdated Show resolved Hide resolved
Sources/Vapor/Logging/Logger+LogError.swift Outdated Show resolved Hide resolved
Tests/VaporTests/LoggingTests.swift Show resolved Hide resolved
Sources/Vapor/Middleware/ErrorMiddleware.swift Outdated Show resolved Hide resolved
@maciejtrybilo
Copy link
Contributor Author

Thanks for the comments @tanner0101 Let me know anything else.

Copy link
Member

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

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

This is great, thanks @maciejtrybilo !

@tanner0101 tanner0101 merged commit 642f3d4 into vapor:3 Feb 15, 2020
@tanner0101
Copy link
Member

@natanrolnik
Copy link

natanrolnik commented Feb 16, 2020

@maciejtrybilo thanks for the PR! From what I looked now, it seems that in ErrorMiddleware in the Vapor 4 Beta we don't have this behavior yet, right @tanner0101 ?
Could this be achieved with a similar approach?

@tanner0101
Copy link
Member

@natanrolnik yeah that's true. An issue for Vapor 4 specifically would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Vapor 3
  
In Progress
Development

Successfully merging this pull request may close these issues.

None yet

4 participants