-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fixes #278: adds support for verbose access logging #279
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ var colors = require('colors'), | |
| httpServer = require('../lib/http-server'), | ||
| portfinder = require('portfinder'), | ||
| opener = require('opener'), | ||
| columnify = require('columnify'), | ||
| argv = require('optimist') | ||
| .boolean('cors') | ||
| .argv; | ||
|
|
@@ -38,6 +39,7 @@ if (argv.h || argv.help) { | |
| ' -K --key Path to ssl key file (default: key.pem).', | ||
| '', | ||
| ' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]', | ||
| ' -v --verbose Log out the full headers of each request along with the typical content', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now have On the other hand, since http-server is pretty verbose by default, I wonder if this might be better called
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also move this up next to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also should to be added to the README and doc/http-server.1 |
||
| ' -h --help Print this list and exit.' | ||
| ].join('\n')); | ||
| process.exit(); | ||
|
|
@@ -68,6 +70,14 @@ if (!argv.s && !argv.silent) { | |
| date, req.method.cyan, req.url.cyan, | ||
| req.headers['user-agent'] | ||
| ); | ||
| if (argv.v || argv.verbose) { | ||
thornjad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| var headerString = columnify(req.headers, | ||
| { columns: ['Header', 'Value'] }); | ||
| logger.info( | ||
| '%s', | ||
| headerString | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that we either don't add a new dependency, or use it for all logging (and the help output).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of adding this dependency. It does make the headers look better, but I'm not sure we need the extra baggage to do that. I think
util.formatshould do just fine without any extra libraries