rslog 1.2.4 → 1.2.5
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/dist/index.js +35 -24
- package/dist/index.mjs +32 -23
- package/package.json +17 -14
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d =
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: definition[key]
|
|
@@ -9,12 +9,10 @@ var __webpack_require__ = {};
|
|
|
9
9
|
};
|
|
10
10
|
})();
|
|
11
11
|
(()=>{
|
|
12
|
-
__webpack_require__.o =
|
|
13
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
-
};
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
15
13
|
})();
|
|
16
14
|
(()=>{
|
|
17
|
-
__webpack_require__.r =
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
18
16
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
17
|
value: 'Module'
|
|
20
18
|
});
|
|
@@ -26,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
26
24
|
var __webpack_exports__ = {};
|
|
27
25
|
__webpack_require__.r(__webpack_exports__);
|
|
28
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
logger: ()=>src_logger,
|
|
28
|
+
createLogger: ()=>createLogger
|
|
31
29
|
});
|
|
32
30
|
const external_node_process_namespaceObject = require("node:process");
|
|
33
31
|
const external_node_os_namespaceObject = require("node:os");
|
|
@@ -43,11 +41,18 @@ let flagForceColor;
|
|
|
43
41
|
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
44
42
|
else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
|
|
45
43
|
function envForceColor() {
|
|
46
|
-
if ('FORCE_COLOR' in env)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
if (!('FORCE_COLOR' in env)) return;
|
|
45
|
+
if ('true' === env.FORCE_COLOR) return 1;
|
|
46
|
+
if ('false' === env.FORCE_COLOR) return 0;
|
|
47
|
+
if (0 === env.FORCE_COLOR.length) return 1;
|
|
48
|
+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
49
|
+
if (![
|
|
50
|
+
0,
|
|
51
|
+
1,
|
|
52
|
+
2,
|
|
53
|
+
3
|
|
54
|
+
].includes(level)) return;
|
|
55
|
+
return level;
|
|
51
56
|
}
|
|
52
57
|
function translateLevel(level) {
|
|
53
58
|
if (0 === level) return false;
|
|
@@ -77,10 +82,13 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
77
82
|
return 1;
|
|
78
83
|
}
|
|
79
84
|
if ('CI' in env) {
|
|
80
|
-
if (
|
|
85
|
+
if ([
|
|
86
|
+
'GITHUB_ACTIONS',
|
|
87
|
+
'GITEA_ACTIONS',
|
|
88
|
+
'CIRCLECI'
|
|
89
|
+
].some((key)=>key in env)) return 3;
|
|
81
90
|
if ([
|
|
82
91
|
'TRAVIS',
|
|
83
|
-
'CIRCLECI',
|
|
84
92
|
'APPVEYOR',
|
|
85
93
|
'GITLAB_CI',
|
|
86
94
|
'BUILDKITE',
|
|
@@ -237,13 +245,12 @@ let createLogger = (options = {})=>{
|
|
|
237
245
|
label = (logType.label || '').padEnd(7);
|
|
238
246
|
label = bold(logType.color ? logType.color(label) : label);
|
|
239
247
|
}
|
|
240
|
-
if (message instanceof Error) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
} else if ('error' === logType.level && 'string' == typeof message) {
|
|
248
|
+
if (message instanceof Error) if (message.stack) {
|
|
249
|
+
let [name, ...rest] = message.stack.split('\n');
|
|
250
|
+
if (name.startsWith('Error: ')) name = name.slice(7);
|
|
251
|
+
text = `${name}\n${gray(rest.join('\n'))}`;
|
|
252
|
+
} else text = message.message;
|
|
253
|
+
else if ('error' === logType.level && 'string' == typeof message) {
|
|
247
254
|
let lines = message.split('\n');
|
|
248
255
|
text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
|
|
249
256
|
} else text = `${message}`;
|
|
@@ -267,8 +274,12 @@ let createLogger = (options = {})=>{
|
|
|
267
274
|
return logger;
|
|
268
275
|
};
|
|
269
276
|
let src_logger = createLogger();
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
277
|
+
exports.createLogger = __webpack_exports__.createLogger;
|
|
278
|
+
exports.logger = __webpack_exports__.logger;
|
|
279
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
280
|
+
"createLogger",
|
|
281
|
+
"logger"
|
|
282
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
283
|
+
Object.defineProperty(exports, '__esModule', {
|
|
273
284
|
value: true
|
|
274
285
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args :
|
|
1
|
+
import external_node_process_default from "node:process";
|
|
2
|
+
import external_node_os_default from "node:os";
|
|
3
|
+
import external_node_tty_default from "node:tty";
|
|
4
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : external_node_process_default.argv) {
|
|
5
5
|
const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
|
|
6
6
|
const position = argv.indexOf(prefix + flag);
|
|
7
7
|
const terminatorPosition = argv.indexOf('--');
|
|
8
8
|
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
9
9
|
}
|
|
10
|
-
const { env } =
|
|
10
|
+
const { env } = external_node_process_default;
|
|
11
11
|
let flagForceColor;
|
|
12
12
|
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
13
13
|
else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
|
|
14
14
|
function envForceColor() {
|
|
15
|
-
if ('FORCE_COLOR' in env)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if (!('FORCE_COLOR' in env)) return;
|
|
16
|
+
if ('true' === env.FORCE_COLOR) return 1;
|
|
17
|
+
if ('false' === env.FORCE_COLOR) return 0;
|
|
18
|
+
if (0 === env.FORCE_COLOR.length) return 1;
|
|
19
|
+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
20
|
+
if (![
|
|
21
|
+
0,
|
|
22
|
+
1,
|
|
23
|
+
2,
|
|
24
|
+
3
|
|
25
|
+
].includes(level)) return;
|
|
26
|
+
return level;
|
|
20
27
|
}
|
|
21
28
|
function translateLevel(level) {
|
|
22
29
|
if (0 === level) return false;
|
|
@@ -40,16 +47,19 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
40
47
|
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
41
48
|
const min = forceColor || 0;
|
|
42
49
|
if ('dumb' === env.TERM) return min;
|
|
43
|
-
if ('win32' ===
|
|
44
|
-
const osRelease =
|
|
50
|
+
if ('win32' === external_node_process_default.platform) {
|
|
51
|
+
const osRelease = external_node_os_default.release().split('.');
|
|
45
52
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
46
53
|
return 1;
|
|
47
54
|
}
|
|
48
55
|
if ('CI' in env) {
|
|
49
|
-
if (
|
|
56
|
+
if ([
|
|
57
|
+
'GITHUB_ACTIONS',
|
|
58
|
+
'GITEA_ACTIONS',
|
|
59
|
+
'CIRCLECI'
|
|
60
|
+
].some((key)=>key in env)) return 3;
|
|
50
61
|
if ([
|
|
51
62
|
'TRAVIS',
|
|
52
|
-
'CIRCLECI',
|
|
53
63
|
'APPVEYOR',
|
|
54
64
|
'GITLAB_CI',
|
|
55
65
|
'BUILDKITE',
|
|
@@ -83,10 +93,10 @@ function createSupportsColor(stream, options = {}) {
|
|
|
83
93
|
}
|
|
84
94
|
const supportsColor = {
|
|
85
95
|
stdout: createSupportsColor({
|
|
86
|
-
isTTY:
|
|
96
|
+
isTTY: external_node_tty_default.isatty(1)
|
|
87
97
|
}),
|
|
88
98
|
stderr: createSupportsColor({
|
|
89
|
-
isTTY:
|
|
99
|
+
isTTY: external_node_tty_default.isatty(2)
|
|
90
100
|
})
|
|
91
101
|
};
|
|
92
102
|
const supports_color = supportsColor;
|
|
@@ -206,13 +216,12 @@ let createLogger = (options = {})=>{
|
|
|
206
216
|
label = (logType.label || '').padEnd(7);
|
|
207
217
|
label = bold(logType.color ? logType.color(label) : label);
|
|
208
218
|
}
|
|
209
|
-
if (message instanceof Error) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
} else if ('error' === logType.level && 'string' == typeof message) {
|
|
219
|
+
if (message instanceof Error) if (message.stack) {
|
|
220
|
+
let [name, ...rest] = message.stack.split('\n');
|
|
221
|
+
if (name.startsWith('Error: ')) name = name.slice(7);
|
|
222
|
+
text = `${name}\n${gray(rest.join('\n'))}`;
|
|
223
|
+
} else text = message.message;
|
|
224
|
+
else if ('error' === logType.level && 'string' == typeof message) {
|
|
216
225
|
let lines = message.split('\n');
|
|
217
226
|
text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
|
|
218
227
|
} else text = `${message}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rslog",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -14,28 +14,31 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"prepare": "rslib build",
|
|
19
|
+
"preview": "bun run ./preview.ts",
|
|
20
|
+
"build": "rslib build",
|
|
21
|
+
"dev": "rslib build --watch",
|
|
22
|
+
"test": "vitest",
|
|
23
|
+
"bump": "npx bumpp"
|
|
24
|
+
},
|
|
25
|
+
"packageManager": "pnpm@10.12.1",
|
|
17
26
|
"repository": {
|
|
18
27
|
"type": "git",
|
|
19
28
|
"url": "https://github.com/rspack-contrib/rslog.git"
|
|
20
29
|
},
|
|
21
30
|
"devDependencies": {
|
|
22
|
-
"@rslib/core": "^0.
|
|
23
|
-
"@types/node": "^22.
|
|
31
|
+
"@rslib/core": "^0.9.2",
|
|
32
|
+
"@types/node": "^22.15.31",
|
|
24
33
|
"prettier": "~3.5.3",
|
|
25
34
|
"strip-ansi": "^7.1.0",
|
|
26
|
-
"supports-color": "^
|
|
27
|
-
"typescript": "~5.8.
|
|
35
|
+
"supports-color": "^10.0.0",
|
|
36
|
+
"typescript": "~5.8.3",
|
|
28
37
|
"vitest": "^2.1.8"
|
|
29
38
|
},
|
|
30
39
|
"publishConfig": {
|
|
31
40
|
"access": "public",
|
|
32
|
-
"registry": "https://registry.npmjs.org/"
|
|
33
|
-
|
|
34
|
-
"scripts": {
|
|
35
|
-
"preview": "bun run ./preview.ts",
|
|
36
|
-
"build": "rslib build",
|
|
37
|
-
"dev": "rslib build --watch",
|
|
38
|
-
"test": "vitest",
|
|
39
|
-
"bump": "npx bumpp"
|
|
41
|
+
"registry": "https://registry.npmjs.org/",
|
|
42
|
+
"provenance": true
|
|
40
43
|
}
|
|
41
|
-
}
|
|
44
|
+
}
|