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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove overly verbose data from custom formatter #8353

Merged
merged 3 commits into from
May 24, 2023

Conversation

cravend
Copy link
Contributor

@cravend cravend commented May 18, 2023

This PR modifies the LogFormatter to filter overly verbose items out of the custom object logged with each entry. Currently, the following items are filtered:

const ignoredCustomData = [
  'time',
  'pid',
  'hostname',
  'msg',
  'res',
  'req',
  'reqId',
  'responseTime',
]

These items are used elsewhere in the log formatter, and including them in the custom object is redundant.

It also adds tests to ensure that these keys are removed.

After:

api | 10:35:43 馃尣 incoming request GET xxx /auth?method=getToken
api | 10:35:43 馃尣 Starting a postgresql pool with 1 connections.
api | 馃棐 Custom
api | {
api |   "prisma": {
api |     "clientVersion": "4.14.0"
api |   },
api |   "target": "quaint::pooled",
api | }
api | 10:35:43 馃尣 request completed 66ms
api | 10:35:43 馃尣 incoming request POST xxx /graphql
api | 10:35:43 馃悰 Parsing request to extract GraphQL parameters
api | 10:35:43 馃悰 Processing GraphQL Parameters
api | 10:35:43 馃悰 graphql-server GraphQL execution started: __REDWOOD__AUTH_GET_CURRENT_USER
api | 10:35:43 馃尣 request completed 21ms
api | 10:35:43 馃悰 graphql-server GraphQL execution completed: __REDWOOD__AUTH_GET_CURRENT_USER
api | 10:35:43 馃悰 Processing GraphQL Parameters done.

Before:

api | 10:35:43 馃尣 incoming request GET xxx /auth?method=getToken
api | 馃棐 Custom
api | {
api |   "time": 1684074943416,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "reqId": "req-1",
api |   "req": {
api |     "method": "GET",
api |     "url": "/auth?method=getToken",
api |     "hostname": "localhost:8910",
api |     "remoteAddress": "::1",
api |     "remotePort": 54521
api |   },
api |   "msg": "incoming request"
api | }
api | 10:35:43 馃尣 Starting a postgresql pool with 1 connections.
api | 馃棐 Custom
api | {
api |   "time": 1684074943437,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "prisma": {
api |     "clientVersion": "4.14.0"
api |   },
api |   "timestamp": "2023-05-14T14:35:43.437Z",
api |   "target": "quaint::pooled",
api |   "msg": "Starting a postgresql pool with 1 connections."
api | }
api | 10:35:43 馃尣 request completed 66ms
api | 馃棐 Custom
api | {
api |   "time": 1684074943482,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "reqId": "req-1",
api |   "res": {
api |     "statusCode": 200
api |   },
api |   "msg": "request completed"
api | }
api | 10:35:43 馃尣 incoming request POST xxx /graphql
api | 馃棐 Custom
api | {
api |   "time": 1684074943545,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "reqId": "req-2",
api |   "req": {
api |     "method": "POST",
api |     "url": "/graphql",
api |     "hostname": "localhost:8910",
api |     "remoteAddress": "::1",
api |     "remotePort": 54524
api |   },
api |   "msg": "incoming request"
api | }
api | 10:35:43 馃悰 Parsing request to extract GraphQL parameters
api | 馃棐 Custom
api | {
api |   "time": 1684074943549,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "msg": "Parsing request to extract GraphQL parameters"
api | }
api | 10:35:43 馃悰 Processing GraphQL Parameters
api | 馃棐 Custom
api | {
api |   "time": 1684074943549,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "msg": "Processing GraphQL Parameters"
api | }
api | 10:35:43 馃悰 graphql-server GraphQL execution started: __REDWOOD__AUTH_GET_CURRENT_USER
api | 馃棐 Custom
api | {
api |   "time": 1684074943564,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "msg": "GraphQL execution started: __REDWOOD__AUTH_GET_CURRENT_USER"
api | }
api | 10:35:43 馃尣 request completed 21ms
api | 馃棐 Custom
api | {
api |   "time": 1684074943567,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "reqId": "req-2",
api |   "res": {
api |     "statusCode": 200
api |   },
api |   "msg": "request completed"
api | }
api | 10:35:43 馃悰 graphql-server GraphQL execution completed: __REDWOOD__AUTH_GET_CURRENT_USER
api | 馃棐 Custom
api | {
api |   "time": 1684074943565,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "msg": "GraphQL execution completed: __REDWOOD__AUTH_GET_CURRENT_USER"
api | }
api | 10:35:43 馃悰 Processing GraphQL Parameters done.
api | 馃棐 Custom
api | {
api |   "time": 1684074943565,
api |   "pid": 30701,
api |   "hostname": "Daltons-Air",
api |   "msg": "Processing GraphQL Parameters done."
api | }

Closes #8318

@replay-io
Copy link

replay-io bot commented May 18, 2023

18 replays were recorded for 18ad691.

image 0 Failed
image 18 Passed

View test run on Replay 鈫楋笌

@dac09
Copy link
Collaborator

dac09 commented May 18, 2023

Thanks for this also @cravend - would you mind updating the description with a couple of screenshots / small description on what this achieves? (hard to tell from the code)

It also helpful for users to see exactly what got merged without diving into the code :)

@dac09 dac09 added the release:fix This PR is a fix label May 18, 2023
@dac09 dac09 self-assigned this May 18, 2023
@cravend
Copy link
Contributor Author

cravend commented May 18, 2023

Thanks for this also @cravend - would you mind updating the description with a couple of screenshots / small description on what this achieves? (hard to tell from the code)

It also helpful for users to see exactly what got merged without diving into the code :)

Done @dac09 :-)

@dthyresson dthyresson self-requested a review May 18, 2023 20:31
@dthyresson dthyresson assigned dthyresson and unassigned dac09 May 18, 2023
@dthyresson dthyresson requested a review from Tobbe May 18, 2023 20:32
@dthyresson
Copy link
Contributor

Thanks @cravend I'll review soon. I had initially thought of a different implementation rather than ignoring those attributes -- but I have to remember what it was (and it may not have worked). Let me try to recall what that was so I can review better.

Thanks so much for taking this on!

Copy link
Contributor

@dthyresson dthyresson left a comment

Choose a reason for hiding this comment

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

Thanks @cravend ! Approved!

Sorry this got off my review list for so long. This definitely makes logs cleaner and easier to read.

I might decide to add in the req url and /or id on the main message line at some point if we find that having the request url in a more serverful log is helpful.

Thanks again and I'll merge when CI completes.

Thanks again!

@dthyresson dthyresson enabled auto-merge (squash) May 24, 2023 21:03
@dthyresson dthyresson merged commit b627156 into redwoodjs:main May 24, 2023
25 checks passed
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone May 24, 2023
@cravend
Copy link
Contributor Author

cravend commented May 24, 2023

Thanks @cravend ! Approved!

Sorry this got off my review list for so long. This definitely makes logs cleaner and easier to read.

I might decide to add in the req url and /or id on the main message line at some point if we find that having the request url in a more serverful log is helpful.

Thanks again and I'll merge when CI completes.

Thanks again!

Sounds good! Thanks :-)

Just so you know, the req url is in the main message already (but ID and hostname are not).

@cravend cravend deleted the djc-simplify-server-logs branch May 24, 2023 22:07
@dthyresson
Copy link
Contributor

Thanks @cravend ! Approved!
Sorry this got off my review list for so long. This definitely makes logs cleaner and easier to read.
I might decide to add in the req url and /or id on the main message line at some point if we find that having the request url in a more serverful log is helpful.
Thanks again and I'll merge when CI completes.
Thanks again!

Sounds good! Thanks :-)

Just so you know, the req url is in the main message already (but ID and hostname are not).

Oh you鈥檙e right. Perfect! Thanks again!

jtoar pushed a commit that referenced this pull request May 25, 2023
* refactor: remove overly verbose data from custom formatter

* test: add tests for LogFormatter custom filter

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
@jtoar jtoar added release:breaking This PR is a breaking change and removed release:fix This PR is a fix labels May 31, 2023
@jtoar
Copy link
Contributor

jtoar commented May 31, 2023

Talked with @thedavidprice, we're not sure if this is breaking or not strictly but since we're taking away information that people could be relying in some edge case in production, we just don't feel comfortable releasing it in a minor. v6 is on the horizon, or at least not too far away, so we'll get this out then. Thanks @cravend!

@jtoar jtoar modified the milestones: next-release, v6.0.0 Jun 1, 2023
jtoar added a commit that referenced this pull request Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:breaking This PR is a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug?]: Re-simplify server logs
4 participants