Skip to content

Commit 31b098e

Browse files
darcyclarkelukekarrys
authored andcommitted
docs: add logging docs
PR-URL: #4113 Credit: @darcyclarke Close: #4113 Reviewed-by: @lukekarrys
1 parent 5e6aea7 commit 31b098e

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

docs/content/using-npm/logging.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Logging
3+
section: 7
4+
description: Why, What & How we Log
5+
---
6+
7+
### Description
8+
9+
The `npm` CLI has various mechanisms for showing different levels of information back to end-users for certain commands, configurations & environments.
10+
11+
### Setting Log Levels
12+
13+
#### `loglevel`
14+
15+
`loglevel` is a global argument/config that can be set to determine the type of information to be displayed.
16+
17+
The default value of `loglevel` is `"notice"` but there are several levels/types of logs available, including:
18+
19+
- `"silent"`
20+
- `"error"`
21+
- `"warn"`
22+
- `"notice"`
23+
- `"http"`
24+
- `"timing"`
25+
- `"info"`
26+
- `"verbose"`
27+
- `"silly"`
28+
29+
All logs pertaining to a level proceeding the current setting will be shown.
30+
31+
All logs are written to a debug log, with the path to that file printed if the execution of a command fails.
32+
33+
##### Aliases
34+
35+
The log levels listed above have various corresponding aliases, including:
36+
37+
- `-d`: `--loglevel info`
38+
- `--dd`: `--loglevel verbose`
39+
- `--verbose`: `--loglevel verbose`
40+
- `--ddd`: `--loglevel silly`
41+
- `-q`: `--loglevel warn`
42+
- `--quiet`: `--loglevel warn`
43+
- `-s`: `--loglevel silent`
44+
- `--silent`: `--loglevel silent`
45+
46+
#### `foreground-scripts`
47+
48+
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`.
49+
50+
### Registry Response Headers
51+
52+
#### `npm-notice`
53+
54+
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.
55+
56+
This header is not cached, and will not be logged if the request is served from the cache.
57+
58+
### See also
59+
60+
* [config](/using-npm/config)

docs/nav.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@
235235
- title: Config
236236
url: /using-npm/config
237237
description: About npm configuration
238+
- title: Logging
239+
url: /using-npm/logging
240+
description: Why, What & How we Log
238241
- title: Scope
239242
url: /using-npm/scope
240243
description: Scoped packages

0 commit comments

Comments
 (0)