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

Rework documentation around formats and custom format functions. #125

Closed
wants to merge 5 commits into from

Conversation

indexzero
Copy link
Contributor

@indexzero indexzero commented Oct 7, 2016

@dougwilson thanks for the feedback on #124. I've reworded what @bmeck wrote incorporating your feedback. Hopefully this will communicate the material more clearly.

📚 📘 Read the rendered Markdown for README.md 📖 📚

@indexzero indexzero mentioned this pull request Oct 7, 2016
@dougwilson
Copy link
Contributor

This looks a lot better :) I do see there are a few things copied from the other PR that I had feedback on. If you can make the adjustments on those items from the comments I made in the other PR, that would be fabulous :) I do have some comments here, but i have to get to sleep for a weekend trip, but I will be back here Tuesday to see what changed and add my additional comments 👍

@indexzero
Copy link
Contributor Author

@dougwilson roger that. Did another pass to clarify the four options folks have:

README.md Outdated

##### Using a format function [from `morgan.compile`](#morgancompileformat)
``` js
morgan(morgan.compile(':method :url :status :res[content-length] - :response-time ms'))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if I want to explain what the difference is between this example and the one above is. I would just leave out this example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated
@@ -20,7 +20,39 @@ var morgan = require('morgan')

Create a new morgan logger middleware function using the given `format` and `options`.
The `format` argument may be a string of a predefined name (see below for the names),
a string of a format string, or a function that will produce a log entry.
a string of a format string, or a format function that will produce a log entry.
Copy link
Contributor

Choose a reason for hiding this comment

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

So the wording is in the format "a ". Can we keep that wording for the function as well? Perhaps "or a function that will format a log entry"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated
a string of a format string, or a function that will produce a log entry.
a string of a format string, or a format function that will produce a log entry.

Format functions accept three arguments `tokens`, `req`, and `res` where `tokens` represents
Copy link
Contributor

Choose a reason for hiding this comment

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

And then probably start this with "The function will be called with three arguments: [...]"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated
an object with all known tokens. It is expected to return a string. For the sake of example, the
following four code snippets are equivalent.

##### Using a [predefined format string](#predefined-formats)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this skipped a level of heading by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated
Calling `morgan.token()` using the same name as an existing token will overwrite that token definition.
There are a few pieces of behavior you should be aware of when using tokens:

- `morgan.token('name', callback)` corresponds to `:name` in any string passed to `morgan(format, options)`.
Copy link
Contributor

@dougwilson dougwilson Oct 12, 2016

Choose a reason for hiding this comment

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

In the Express.js readmes, we usually format the bullet lists as "<space><space>*<space>"

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, let's not call the function callback, as that has a significance in the Node.js land, and this is not a function that is in the form of a callback (it's sync and isn't called with err as the first argument).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated

morgan.token('process', function getId (req, res, arg) {
if (typeof process[arg] === 'function') {
return String(process[arg]())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line misses the functionality for taking advantage of the built-in falsy behavior,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated
var morgan = require('morgan')

var route = morgan.compile(':method :url')
var outputJson = function (tokens, req, res) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not used a named function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated
var outputJson = function (tokens, req, res) {
return JSON.stringify({
route: route(tokens, req, res),
status: morgan.status(req, res),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this a typo: "morgan" should probably be "tokens" on this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated
return JSON.stringify({
route: route(tokens, req, res),
status: morgan.status(req, res),
'content-length': morgan.res(req, res, 'content-length')
Copy link
Contributor

Choose a reason for hiding this comment

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

Same morgan -> tokens typo on this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

README.md Outdated
A request to `GET /` would cause `morgan` to log the following JSON:

``` json
{ "route": "GET /", "status": 200, "content-length": 13 }
Copy link
Contributor

Choose a reason for hiding this comment

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

So we don't have any examples of the output for any other example apps above. If we include an example, shouldn't it at least be exactly what the user would see? I don't think JSON.stringify includes those space characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed this in 1c9416c. Not sure why this Github comment wasn't hidden automatically because the line was changed.

@indexzero
Copy link
Contributor Author

indexzero commented Oct 12, 2016

I will make the changes you requested, but I'd like to point out that this has been far more difficult than I expected. I almost just gave up.

One tactic I've used to encourage contribution when I have very particular requirements about nuance is to simply merge the PR and clean it up myself. You may think this is more of a time suck but in my experience I've found it's as time consuming as giving a detailed PR review as you have here.So the net-net time is the same.

@dougwilson
Copy link
Contributor

It's a difficult balance. I used to do that post merge clean up, but I would consistently get angry people, accusing me of not merging what they wanted. I just gave up on that, because it was not a happy place to be in where I thought I was helping but getting yelled at.

If you are giving me permission to do that, I can do that, though. Hopefully you'll agree with the changes I make, though, because I have had a consistently bad experience doing what you are asking me to do.

@indexzero
Copy link
Contributor Author

@dougwilson made all the changes you asked for. At this point I'd simply like to see this land. Feel free to make any future edits post-merge.

@indexzero
Copy link
Contributor Author

@dougwilson bump.

@dougwilson
Copy link
Contributor

Hi @indexzero, I haven't forgotten about your PR. I just have to make those "post-merge" edits, but have not been at a computer very much in order to do this. I'll take care of this as soon as I can.

@dougwilson dougwilson closed this in 78aee59 Feb 4, 2017
@indexzero
Copy link
Contributor Author

Thanks for following up and cherry-picking this.

@indexzero indexzero deleted the doc-redux branch February 16, 2017 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants