@docusaurus/logger 2.0.0-beta.18 → 2.0.0-beta.21
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.
- package/README.md +22 -7
- package/lib/__mocks__/chalk.d.ts +70 -0
- package/lib/__mocks__/chalk.d.ts.map +1 -0
- package/lib/__mocks__/chalk.js +11 -0
- package/lib/__mocks__/chalk.js.map +1 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -12
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +13 -12
package/README.md
CHANGED
|
@@ -7,19 +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
|
-
-
|
|
11
|
-
- `
|
|
12
|
-
- `
|
|
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.
|
|
16
|
+
- `path`: formats a file path.
|
|
17
|
+
- `url`: formats a URL.
|
|
18
|
+
- `name`: formats an identifier.
|
|
13
19
|
- `code`: formats a code snippet.
|
|
14
20
|
- `subdue`: subdues the text.
|
|
15
21
|
- `num`: formats a number.
|
|
16
|
-
- The `interpolate` function. It is a template literal tag.
|
|
17
|
-
- Logging functions. All logging functions can both be used as functions (
|
|
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.
|
|
18
24
|
- `info`: prints information.
|
|
19
25
|
- `warn`: prints a warning that should be payed attention to.
|
|
20
26
|
- `error`: prints an error (not necessarily halting the program) that signals significant problems.
|
|
21
27
|
- `success`: prints a success message.
|
|
22
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
|
+
|
|
23
37
|
### Using the template literal tag
|
|
24
38
|
|
|
25
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:
|
|
@@ -31,10 +45,11 @@ logger.info`Hello name=${name}! You have number=${money} dollars. Here are the $
|
|
|
31
45
|
To buy anything, enter code=${'buy x'} where code=${'x'} is the item's name; to quit, press code=${'Ctrl + C'}.`;
|
|
32
46
|
```
|
|
33
47
|
|
|
34
|
-
An embedded expression is optionally preceded by a flag in the form
|
|
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:
|
|
35
49
|
|
|
36
50
|
- `path=`: `path`
|
|
37
|
-
- `
|
|
51
|
+
- `url=`: `url`
|
|
52
|
+
- `name=`: `name`
|
|
38
53
|
- `code=`: `code`
|
|
39
54
|
- `subdue=`: `subdue`
|
|
40
55
|
- `number=`: `num`
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
declare const _exports: {
|
|
2
|
+
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
|
3
|
+
(...text: unknown[]): string;
|
|
4
|
+
Instance: chalk.Instance;
|
|
5
|
+
level: chalk.Level;
|
|
6
|
+
hex(color: string): chalk.Chalk;
|
|
7
|
+
keyword(color: string): chalk.Chalk;
|
|
8
|
+
rgb(red: number, green: number, blue: number): chalk.Chalk;
|
|
9
|
+
hsl(hue: number, saturation: number, lightness: number): chalk.Chalk;
|
|
10
|
+
hsv(hue: number, saturation: number, value: number): chalk.Chalk;
|
|
11
|
+
hwb(hue: number, whiteness: number, blackness: number): chalk.Chalk;
|
|
12
|
+
ansi(code: number): chalk.Chalk;
|
|
13
|
+
ansi256(index: number): chalk.Chalk;
|
|
14
|
+
bgHex(color: string): chalk.Chalk;
|
|
15
|
+
bgKeyword(color: string): chalk.Chalk;
|
|
16
|
+
bgRgb(red: number, green: number, blue: number): chalk.Chalk;
|
|
17
|
+
bgHsl(hue: number, saturation: number, lightness: number): chalk.Chalk;
|
|
18
|
+
bgHsv(hue: number, saturation: number, value: number): chalk.Chalk;
|
|
19
|
+
bgHwb(hue: number, whiteness: number, blackness: number): chalk.Chalk;
|
|
20
|
+
bgAnsi(code: number): chalk.Chalk;
|
|
21
|
+
bgAnsi256(index: number): chalk.Chalk;
|
|
22
|
+
readonly reset: chalk.Chalk;
|
|
23
|
+
readonly bold: chalk.Chalk;
|
|
24
|
+
readonly dim: chalk.Chalk;
|
|
25
|
+
readonly italic: chalk.Chalk;
|
|
26
|
+
readonly underline: chalk.Chalk;
|
|
27
|
+
readonly inverse: chalk.Chalk;
|
|
28
|
+
readonly hidden: chalk.Chalk;
|
|
29
|
+
readonly strikethrough: chalk.Chalk;
|
|
30
|
+
readonly visible: chalk.Chalk;
|
|
31
|
+
readonly black: chalk.Chalk;
|
|
32
|
+
readonly red: chalk.Chalk;
|
|
33
|
+
readonly green: chalk.Chalk;
|
|
34
|
+
readonly yellow: chalk.Chalk;
|
|
35
|
+
readonly blue: chalk.Chalk;
|
|
36
|
+
readonly magenta: chalk.Chalk;
|
|
37
|
+
readonly cyan: chalk.Chalk;
|
|
38
|
+
readonly white: chalk.Chalk;
|
|
39
|
+
readonly gray: chalk.Chalk;
|
|
40
|
+
readonly grey: chalk.Chalk;
|
|
41
|
+
readonly blackBright: chalk.Chalk;
|
|
42
|
+
readonly redBright: chalk.Chalk;
|
|
43
|
+
readonly greenBright: chalk.Chalk;
|
|
44
|
+
readonly yellowBright: chalk.Chalk;
|
|
45
|
+
readonly blueBright: chalk.Chalk;
|
|
46
|
+
readonly magentaBright: chalk.Chalk;
|
|
47
|
+
readonly cyanBright: chalk.Chalk;
|
|
48
|
+
readonly whiteBright: chalk.Chalk;
|
|
49
|
+
readonly bgBlack: chalk.Chalk;
|
|
50
|
+
readonly bgRed: chalk.Chalk;
|
|
51
|
+
readonly bgGreen: chalk.Chalk;
|
|
52
|
+
readonly bgYellow: chalk.Chalk;
|
|
53
|
+
readonly bgBlue: chalk.Chalk;
|
|
54
|
+
readonly bgMagenta: chalk.Chalk;
|
|
55
|
+
readonly bgCyan: chalk.Chalk;
|
|
56
|
+
readonly bgWhite: chalk.Chalk;
|
|
57
|
+
readonly bgGray: chalk.Chalk;
|
|
58
|
+
readonly bgGrey: chalk.Chalk;
|
|
59
|
+
readonly bgBlackBright: chalk.Chalk;
|
|
60
|
+
readonly bgRedBright: chalk.Chalk;
|
|
61
|
+
readonly bgGreenBright: chalk.Chalk;
|
|
62
|
+
readonly bgYellowBright: chalk.Chalk;
|
|
63
|
+
readonly bgBlueBright: chalk.Chalk;
|
|
64
|
+
readonly bgMagentaBright: chalk.Chalk;
|
|
65
|
+
readonly bgCyanBright: chalk.Chalk;
|
|
66
|
+
readonly bgWhiteBright: chalk.Chalk;
|
|
67
|
+
};
|
|
68
|
+
export = _exports;
|
|
69
|
+
import chalk = require("chalk");
|
|
70
|
+
//# sourceMappingURL=chalk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chalk.d.ts","sourceRoot":"","sources":["../../src/__mocks__/chalk.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
const chalk = require('chalk');
|
|
9
|
+
// Force coloring the output even in CI
|
|
10
|
+
module.exports = new chalk.Instance({ level: 3 });
|
|
11
|
+
//# sourceMappingURL=chalk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chalk.js","sourceRoot":"","sources":["../../src/__mocks__/chalk.js"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B,uCAAuC;AACvC,MAAM,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -23,10 +23,11 @@ declare const logger: {
|
|
|
23
23
|
bold: chalk.Chalk;
|
|
24
24
|
dim: chalk.Chalk;
|
|
25
25
|
path: (msg: unknown) => string;
|
|
26
|
+
url: (msg: unknown) => string;
|
|
26
27
|
name: (msg: unknown) => string;
|
|
27
28
|
code: (msg: unknown) => string;
|
|
28
|
-
subdue:
|
|
29
|
-
num:
|
|
29
|
+
subdue: (msg: unknown) => string;
|
|
30
|
+
num: (msg: unknown) => string;
|
|
30
31
|
interpolate: typeof interpolate;
|
|
31
32
|
info: typeof info;
|
|
32
33
|
warn: typeof warn;
|
|
@@ -34,5 +35,5 @@ declare const logger: {
|
|
|
34
35
|
success: typeof success;
|
|
35
36
|
newLine: typeof newLine;
|
|
36
37
|
};
|
|
37
|
-
export
|
|
38
|
+
export = logger;
|
|
38
39
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d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KAAG,MAAM;kBACd,OAAO,KAAG,MAAM;eACnB,OAAO,KAAG,MAAM;;;;;;;CAmIjC,CAAC;AAIF,SAAS,MAAM,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
8
|
const tslib_1 = require("tslib");
|
|
10
9
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
11
|
-
const path = (msg) => chalk_1.default.cyan
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
10
|
+
const path = (msg) => chalk_1.default.cyan.underline(`"${String(msg)}"`);
|
|
11
|
+
const url = (msg) => chalk_1.default.cyan.underline(msg);
|
|
12
|
+
const name = (msg) => chalk_1.default.blue.bold(msg);
|
|
13
|
+
const code = (msg) => chalk_1.default.cyan(`\`${String(msg)}\``);
|
|
14
|
+
const subdue = (msg) => chalk_1.default.gray(msg);
|
|
15
|
+
const num = (msg) => chalk_1.default.yellow(msg);
|
|
16
16
|
function interpolate(msgs, ...values) {
|
|
17
17
|
let res = '';
|
|
18
18
|
values.forEach((value, idx) => {
|
|
@@ -25,6 +25,8 @@ function interpolate(msgs, ...values) {
|
|
|
25
25
|
switch (flag[0]) {
|
|
26
26
|
case 'path=':
|
|
27
27
|
return path;
|
|
28
|
+
case 'url=':
|
|
29
|
+
return url;
|
|
28
30
|
case 'number=':
|
|
29
31
|
return num;
|
|
30
32
|
case 'name=':
|
|
@@ -51,7 +53,7 @@ function stringify(msg) {
|
|
|
51
53
|
return String(msg);
|
|
52
54
|
}
|
|
53
55
|
function info(msg, ...values) {
|
|
54
|
-
console.info(`${chalk_1.default.cyan
|
|
56
|
+
console.info(`${chalk_1.default.cyan.bold('[INFO]')} ${values.length === 0
|
|
55
57
|
? stringify(msg)
|
|
56
58
|
: interpolate(msg, ...values)}`);
|
|
57
59
|
}
|
|
@@ -66,7 +68,7 @@ function error(msg, ...values) {
|
|
|
66
68
|
: interpolate(msg, ...values)}`));
|
|
67
69
|
}
|
|
68
70
|
function success(msg, ...values) {
|
|
69
|
-
console.log(`${chalk_1.default.green
|
|
71
|
+
console.log(`${chalk_1.default.green.bold('[SUCCESS]')} ${values.length === 0
|
|
70
72
|
? stringify(msg)
|
|
71
73
|
: interpolate(msg, ...values)}`);
|
|
72
74
|
}
|
|
@@ -80,6 +82,7 @@ const logger = {
|
|
|
80
82
|
bold: chalk_1.default.bold,
|
|
81
83
|
dim: chalk_1.default.dim,
|
|
82
84
|
path,
|
|
85
|
+
url,
|
|
83
86
|
name,
|
|
84
87
|
code,
|
|
85
88
|
subdue,
|
|
@@ -91,9 +94,5 @@ const logger = {
|
|
|
91
94
|
success,
|
|
92
95
|
newLine,
|
|
93
96
|
};
|
|
94
|
-
// TODO remove when migrating to ESM
|
|
95
|
-
// logger can only be default-imported in ESM with this
|
|
96
97
|
module.exports = logger;
|
|
97
|
-
module.exports.default = logger;
|
|
98
|
-
exports.default = logger;
|
|
99
98
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,0DAA0B;AAI1B,MAAM,IAAI,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAChF,MAAM,GAAG,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAChE,MAAM,IAAI,GAAG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ulated logger for semantically formatting console messages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"chalk": "^4.1.2",
|
|
24
|
-
"tslib": "^2.
|
|
24
|
+
"tslib": "^2.4.0"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=14"
|
|
27
|
+
"node": ">=16.14"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/supports-color": "^8.1.1"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "69ac49fc6909517f13615ee40290c4bd00c39df4"
|
|
33
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import chalk
|
|
8
|
+
import chalk from 'chalk';
|
|
9
9
|
|
|
10
10
|
type InterpolatableValue = string | number | (string | number)[];
|
|
11
11
|
|
|
12
|
-
const path = (msg: unknown): string => chalk.cyan
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
12
|
+
const path = (msg: unknown): string => chalk.cyan.underline(`"${String(msg)}"`);
|
|
13
|
+
const url = (msg: unknown): string => chalk.cyan.underline(msg);
|
|
14
|
+
const name = (msg: unknown): string => chalk.blue.bold(msg);
|
|
15
|
+
const code = (msg: unknown): string => chalk.cyan(`\`${String(msg)}\``);
|
|
16
|
+
const subdue = (msg: unknown): string => chalk.gray(msg);
|
|
17
|
+
const num = (msg: unknown): string => chalk.yellow(msg);
|
|
17
18
|
|
|
18
19
|
function interpolate(
|
|
19
20
|
msgs: TemplateStringsArray,
|
|
@@ -30,6 +31,8 @@ function interpolate(
|
|
|
30
31
|
switch (flag[0]) {
|
|
31
32
|
case 'path=':
|
|
32
33
|
return path;
|
|
34
|
+
case 'url=':
|
|
35
|
+
return url;
|
|
33
36
|
case 'number=':
|
|
34
37
|
return num;
|
|
35
38
|
case 'name=':
|
|
@@ -66,7 +69,7 @@ function info(
|
|
|
66
69
|
): void;
|
|
67
70
|
function info(msg: unknown, ...values: InterpolatableValue[]): void {
|
|
68
71
|
console.info(
|
|
69
|
-
`${chalk.cyan
|
|
72
|
+
`${chalk.cyan.bold('[INFO]')} ${
|
|
70
73
|
values.length === 0
|
|
71
74
|
? stringify(msg)
|
|
72
75
|
: interpolate(msg as TemplateStringsArray, ...values)
|
|
@@ -112,7 +115,7 @@ function success(
|
|
|
112
115
|
): void;
|
|
113
116
|
function success(msg: unknown, ...values: InterpolatableValue[]): void {
|
|
114
117
|
console.log(
|
|
115
|
-
`${chalk.green
|
|
118
|
+
`${chalk.green.bold('[SUCCESS]')} ${
|
|
116
119
|
values.length === 0
|
|
117
120
|
? stringify(msg)
|
|
118
121
|
: interpolate(msg as TemplateStringsArray, ...values)
|
|
@@ -131,6 +134,7 @@ const logger = {
|
|
|
131
134
|
bold: chalk.bold,
|
|
132
135
|
dim: chalk.dim,
|
|
133
136
|
path,
|
|
137
|
+
url,
|
|
134
138
|
name,
|
|
135
139
|
code,
|
|
136
140
|
subdue,
|
|
@@ -145,7 +149,4 @@ const logger = {
|
|
|
145
149
|
|
|
146
150
|
// TODO remove when migrating to ESM
|
|
147
151
|
// logger can only be default-imported in ESM with this
|
|
148
|
-
|
|
149
|
-
module.exports.default = logger;
|
|
150
|
-
|
|
151
|
-
export default logger;
|
|
152
|
+
export = logger;
|