@docusaurus/logger 0.0.0-4947 → 0.0.0-4953

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +19 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -7,20 +7,33 @@ An encapsulated logger for semantically formatting console messages.
7
7
  It exports a single object as default export: `logger`. `logger` has the following properties:
8
8
 
9
9
  - Some useful colors.
10
- - Formatters. These functions have the same signature as the formatters of `picocolors`. Note that their implementations are not guaranteed. You should only care about their semantics.
10
+ - `red`
11
+ - `yellow`
12
+ - `green`
13
+ - `bold`
14
+ - `dim`
15
+ - Formatters. These functions all have the signature `(msg: unknown) => string`. Note that their implementations are not guaranteed. You should only care about their semantics.
11
16
  - `path`: formats a file path.
12
17
  - `url`: formats a URL.
13
- - `id`: formats an identifier.
18
+ - `name`: formats an identifier.
14
19
  - `code`: formats a code snippet.
15
20
  - `subdue`: subdues the text.
16
21
  - `num`: formats a number.
17
- - The `interpolate` function. It is a template literal tag.
18
- - Logging functions. All logging functions can both be used as functions (in which it has the same usage as `console.log`) or template literal tags.
22
+ - The `interpolate` function. It is a template literal tag. The syntax can be found below.
23
+ - Logging functions. All logging functions can both be used as normal functions (similar to the `console.log` family, but only accepts one parameter) or template literal tags.
19
24
  - `info`: prints information.
20
25
  - `warn`: prints a warning that should be payed attention to.
21
26
  - `error`: prints an error (not necessarily halting the program) that signals significant problems.
22
27
  - `success`: prints a success message.
23
28
 
29
+ ### A word on the `error` formatter
30
+
31
+ Beware that an `error` message, even when it doesn't hang the program, is likely going to cause confusion. When users inspect logs and find an `[ERROR]`, even when the build succeeds, they will assume something is going wrong. Use it sparingly.
32
+
33
+ Docusaurus only uses `logger.error` when printing messages immediately before throwing an error, or when user has set the reporting severity of `onBrokenLink`, etc. to `"error"`.
34
+
35
+ In addition, `warn` and `error` will color the **entire** message for better attention. If you are printing large blocks of help text about an error, better use `logger.info`.
36
+
24
37
  ### Using the template literal tag
25
38
 
26
39
  The template literal tag evaluates the template and expressions embedded. `interpolate` returns a new string, while other logging functions prints it. Below is a typical usage:
@@ -32,11 +45,11 @@ logger.info`Hello name=${name}! You have number=${money} dollars. Here are the $
32
45
  To buy anything, enter code=${'buy x'} where code=${'x'} is the item's name; to quit, press code=${'Ctrl + C'}.`;
33
46
  ```
34
47
 
35
- An embedded expression is optionally preceded by a flag in the form `%[a-z]+` (a percentage sign followed by a few lowercase letters). If it's not preceded by any flag, it's printed out as-is. Otherwise, it's formatted with one of the formatters:
48
+ An embedded expression is optionally preceded by a flag in the form `[a-z]+=` (a few lowercase letters, followed by an equals sign, directly preceding the embedded expression). If the expression is not preceded by any flag, it's printed out as-is. Otherwise, it's formatted with one of the formatters:
36
49
 
37
50
  - `path=`: `path`
38
51
  - `url=`: `url`
39
- - `name=`: `id`
52
+ - `name=`: `name`
40
53
  - `code=`: `code`
41
54
  - `subdue=`: `subdue`
42
55
  - `number=`: `num`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/logger",
3
- "version": "0.0.0-4947",
3
+ "version": "0.0.0-4953",
4
4
  "description": "An encapsulated logger for semantically formatting console messages.",
5
5
  "main": "./lib/index.js",
6
6
  "repository": {
@@ -29,5 +29,5 @@
29
29
  "devDependencies": {
30
30
  "@types/supports-color": "^8.1.1"
31
31
  },
32
- "gitHead": "29ca5e7b0c611abdb0a1833411adc26873aee174"
32
+ "gitHead": "743ce473689da566f982a0fff79c71dc24d7a573"
33
33
  }