Skip to content

feat(cli): add --loglevel option#2992

Merged
ikatyang merged 9 commits intoprettier:masterfrom
ikatyang:feat/log-level
Oct 14, 2017
Merged

feat(cli): add --loglevel option#2992
ikatyang merged 9 commits intoprettier:masterfrom
ikatyang:feat/log-level

Conversation

@ikatyang
Copy link
Copy Markdown
Member

@ikatyang ikatyang commented Oct 8, 2017

Fixes #2939

  • Use environment variable PRETTIER_LOG_LEVEL internally.
  • Use chalk directly since debug enforces trailing +0mss and it looks weird in some cases.
  • Prefix every message to stderr with its loglevel, e.g. error, warn, etc.
  • Move unknown minimist option to normalizeConfig

Question:

  • Should we output --debug-check results to stdout? We now prefix every message to stderr with error/warn/etc. and its functionality looks similar to --list-different.


exports[`deprecated options are warned (stderr) 1`] = `
"\`--flow-parser\` is deprecated. Use \`--parser flow\` instead.
"warn \`--flow-parser\` is deprecated. Use \`--parser flow\` instead.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we change it to

warn: `--flow-parser` is deprecated...

or

[warn] `--flow-parser` is deprecated...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

image

[xxx] looks better to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. It was just but strange without punctuation and without color.


exports[`show all logs with --loglevel debug (stderr) 1`] = `
"[warn] Ignored unknown option: --unknown-option
[debug] normalized argv: {\\"_\\":[\\"not-found.js\\"],\\"bracket-spacing\\":false,\\"color\\":true,\\"debug-check\\":false,\\"debug-print-doc\\":false,\\"flow-parser\\":false,\\"insert-pragma\\":false,\\"jsx-bracket-same-line\\":false,\\"list-different\\":false,\\"require-pragma\\":false,\\"semi\\":false,\\"single-quote\\":false,\\"stdin\\":false,\\"use-tabs\\":false,\\"version\\":false,\\"with-node-modules\\":false,\\"write\\":false,\\"loglevel\\":\\"debug\\",\\"parser\\":\\"unknown-parser\\",\\"ignore-path\\":\\".prettierignore\\",\\"config-precedence\\":\\"cli-override\\"}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this test prone to breaking?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It seems it'd be better to use expect(...).toMatch(/[loglevel]/) in this case.

expect(result.stderr).toMatch(pattern);
});
} else {
expect(result.stderr).toMatch(/\s*/);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is this supposed to do? Any string matches /\s*/, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops, I forgot to add ^+$

@ikatyang ikatyang merged commit 2ef879f into prettier:master Oct 14, 2017
@ikatyang ikatyang deleted the feat/log-level branch October 14, 2017 01:17
lipis added a commit to lipis/prettier that referenced this pull request Oct 14, 2017
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --loglevel option

3 participants