-
Notifications
You must be signed in to change notification settings - Fork 3.8k
docs: add new section based around logging #4113
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| title: Logging | ||
| section: 7 | ||
| description: Why, What & How we Log | ||
| --- | ||
|
|
||
| ### Description | ||
|
|
||
| The `npm` CLI has various mechanisms for showing different levels of information back to end-users for certain commands, configurations & environments. | ||
|
|
||
| ### Setting Log Levels | ||
|
|
||
| #### `loglevel` | ||
|
|
||
| `loglevel` is a global argument/config that can be set to determine the type of information to be displayed. | ||
|
|
||
| The default value of `loglevel` is `"notice"` but there are several levels/types of logs available, including: | ||
|
|
||
| - `"silent"` | ||
| - `"error"` | ||
| - `"warn"` | ||
| - `"notice"` | ||
| - `"http"` | ||
| - `"timing"` | ||
| - `"info"` | ||
| - `"verbose"` | ||
| - `"silly"` | ||
|
|
||
| All logs pertaining to a level proceeding the current setting will be shown. | ||
|
|
||
| All logs are written to a debug log, with the path to that file printed if the execution of a command fails. | ||
|
|
||
| ##### Aliases | ||
|
|
||
| The log levels listed above have various corresponding aliases, including: | ||
|
|
||
| - `-d`: `--loglevel info` | ||
| - `--dd`: `--loglevel verbose` | ||
| - `--verbose`: `--loglevel verbose` | ||
| - `--ddd`: `--loglevel silly` | ||
| - `-q`: `--loglevel warn` | ||
| - `--quiet`: `--loglevel warn` | ||
| - `-s`: `--loglevel silent` | ||
| - `--silent`: `--loglevel silent` | ||
|
|
||
| #### `foreground-scripts` | ||
|
|
||
| The `npm` CLI began hiding the output of lifecycle scripts for `npm install` as of `v7`. Notably, this means you will not see logs/output from packages that may be using "install scripts" to display information back to you or from your own project's scripts defined in `package.json`. If you'd like to change this behavior & log this output you can set `foreground-scripts` to `true`. | ||
|
|
||
| ### Registry Response Headers | ||
|
|
||
| #### `npm-notice` | ||
|
|
||
| The `npm` CLI reads from & logs any `npm-notice` headers that are returned from the configured registry. This mechanism can be used by third-party registries to provide useful information when network-dependent requests occur. | ||
|
|
||
| This header is not cached, and will not be logged if the request is served from the cache. | ||
|
|
||
| ### See also | ||
|
|
||
| * [config](/using-npm/config) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.