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

[WIP] Logging #209

Closed
wants to merge 11 commits into from
Closed

Conversation

dotnetCarpenter
Copy link
Collaborator

This is my initial idea on how to provide logging for ecstatic.

The PR is only half done but the tests and main output is done.

TODO:

  • Tests
  • Documentation
  • Refactor middleware to be able to log all status codes and response length
  • Finish getNscaDateTime to handle all time zones

I think this is a candidate for a minor release.

Unfortunately, I don't have time to finish this, this year. If you @jfhbrook or someone else have time, I would love to review.

I noticed that the log code path is run two times for each request, which means that the middleware is run two times for each request but I don't understand why we would do that. The second time the req.method is undefined and req.url is encoded.

@dotnetCarpenter
Copy link
Collaborator Author

hehe failing in node 4 and 5 after I followed airBnB's eslint - dropping node 4 and 5 support to destructuring assignment or make two small fixes in tests... yaa, remove destructuring - it also sounds so negative.

@@ -0,0 +1,11 @@
/* IMPORTANT
Copy link
Owner

Choose a reason for hiding this comment

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

what is this :o

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a comment in the test about how to generate the file

@dotnetCarpenter
Copy link
Collaborator Author

Ref: #208

@dotnetCarpenter
Copy link
Collaborator Author

@jfhbrook What do you think about the idea and about refactoring middleware - would you be up for doing it? Also do you know why the middleware is run twice for each request?

@dotnetCarpenter
Copy link
Collaborator Author

Looks like codecov is broken somehow.. I'll take a quick look

@dotnetCarpenter dotnetCarpenter mentioned this pull request Dec 16, 2017
@codecov-io
Copy link

codecov-io commented Dec 16, 2017

Codecov Report

Merging #209 into master will decrease coverage by 0.07%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #209      +/-   ##
==========================================
- Coverage   75.86%   75.79%   -0.08%     
==========================================
  Files           9        9              
  Lines         518      533      +15     
  Branches      117      122       +5     
==========================================
+ Hits          393      404      +11     
  Misses         45       45              
- Partials       80       84       +4
Impacted Files Coverage Δ
lib/ecstatic/opts.js 77.39% <66.66%> (-0.87%) ⬇️
lib/ecstatic.js 74.58% <84.21%> (+0.82%) ⬆️
lib/ecstatic/show-dir/index.js 73.68% <0%> (-1.32%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 523f273...bb888b4. Read the comment docs.

@dotnetCarpenter
Copy link
Collaborator Author

dotnetCarpenter commented Dec 16, 2017

I'm using this branch of ecstatic, to serve svg and image files to another node program and I never see double logging (re-run of middleware for each request), which leads me to believe that this only happens when requesting via a browser. I was using Chrome..
I'm guessing it could be OPTION or prefetch request that we are not handling very well. It's not completely b0rken but pretty bad for logging and probably has other side-effects.

@jfhbrook
Copy link
Owner

I know there's code branches that call the original middleware recursively, those would probably be candidates for ways to cause double-logging.

I'm down to do some middleware refactors in general, given I have the time and the understanding necessary to make useful ones. This might also touch on #193 #154 #88

@dotnetCarpenter
Copy link
Collaborator Author

R. I. P.
#259

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.

None yet

3 participants