@sprucelabs/spruce-skill-utils 31.2.17 → 31.2.19
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.
|
@@ -13,16 +13,16 @@ const getMaxLogPrefixesLength = () => {
|
|
|
13
13
|
: undefined;
|
|
14
14
|
};
|
|
15
15
|
export default function buildLog(prefix = undefined, options) {
|
|
16
|
-
var _a, _b, _c, _d, _e;
|
|
16
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17
17
|
const { colors = {}, log, useColors } = options !== null && options !== void 0 ? options : {};
|
|
18
18
|
const { info = 'yellow', error = 'red' } = colors;
|
|
19
|
-
const isInteractive = (_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.stdout) === null || _b === void 0 ? void 0 : _b.isTTY;
|
|
19
|
+
const isInteractive = (_c = (_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.stdout) === null || _b === void 0 ? void 0 : _b.isTTY) !== null && _c !== void 0 ? _c : false;
|
|
20
20
|
const shouldUseColors = useColors !== false && isInteractive;
|
|
21
21
|
const pre = prefix ? `${prefix} ::` : undefined;
|
|
22
22
|
const transports = {
|
|
23
|
-
ERROR: (
|
|
24
|
-
INFO: (
|
|
25
|
-
WARN: (
|
|
23
|
+
ERROR: (_d = options === null || options === void 0 ? void 0 : options.transportsByLevel) === null || _d === void 0 ? void 0 : _d.ERROR,
|
|
24
|
+
INFO: (_e = options === null || options === void 0 ? void 0 : options.transportsByLevel) === null || _e === void 0 ? void 0 : _e.INFO,
|
|
25
|
+
WARN: (_f = options === null || options === void 0 ? void 0 : options.transportsByLevel) === null || _f === void 0 ? void 0 : _f.WARN,
|
|
26
26
|
};
|
|
27
27
|
const logUtil = {
|
|
28
28
|
prefix,
|
|
@@ -59,7 +59,7 @@ export default function buildLog(prefix = undefined, options) {
|
|
|
59
59
|
}
|
|
60
60
|
function write(chalkMethod, rawArgs, level) {
|
|
61
61
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
62
|
-
if (!shouldWrite((_c = (_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.LOG_LEVEL) !== null && _c !== void 0 ? _c :
|
|
62
|
+
if (!shouldWrite((_c = (_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.LOG_LEVEL) !== null && _c !== void 0 ? _c : undefined, level)) {
|
|
63
63
|
return '';
|
|
64
64
|
}
|
|
65
65
|
const args = rawArgs.map((a) => { var _a, _b; return (_b = (_a = a === null || a === void 0 ? void 0 : a.toString) === null || _a === void 0 ? void 0 : _a.call(a)) !== null && _b !== void 0 ? _b : 'undefined'; });
|
|
@@ -104,8 +104,8 @@ export default function buildLog(prefix = undefined, options) {
|
|
|
104
104
|
: ((_h = console[logMethod]) !== null && _h !== void 0 ? _h : console.log).bind(console));
|
|
105
105
|
let message = shouldUseColors === false
|
|
106
106
|
? `(${level})${prefix}`
|
|
107
|
-
: chalkMethod(...chalkArgs);
|
|
108
|
-
if (env.
|
|
107
|
+
: chalkMethod === null || chalkMethod === void 0 ? void 0 : chalkMethod(...chalkArgs);
|
|
108
|
+
if (env.SHOULD_LOG_TIME_DELTAS !== 'false') {
|
|
109
109
|
const now = Date.now();
|
|
110
110
|
const diff = now - lastLogTimeMs;
|
|
111
111
|
lastLogTimeMs = now;
|
|
@@ -134,14 +134,15 @@ export const stubLog = buildLog('STUB', {
|
|
|
134
134
|
useColors: false,
|
|
135
135
|
});
|
|
136
136
|
function shouldWrite(maxLogLevel, level) {
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
var _a, _b, _c, _d, _e, _f;
|
|
138
|
+
if (maxLogLevel) {
|
|
139
|
+
if (((_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.LOG_LEVEL) == 'none') {
|
|
139
140
|
return false;
|
|
140
141
|
}
|
|
141
|
-
if (
|
|
142
|
+
if (((_d = (_c = getProcess()) === null || _c === void 0 ? void 0 : _c.env) === null || _d === void 0 ? void 0 : _d.LOG_LEVEL) == 'error' && level !== 'ERROR') {
|
|
142
143
|
return false;
|
|
143
144
|
}
|
|
144
|
-
if (
|
|
145
|
+
if (((_f = (_e = getProcess()) === null || _e === void 0 ? void 0 : _e.env) === null || _f === void 0 ? void 0 : _f.LOG_LEVEL) == 'warn' && level === 'INFO') {
|
|
145
146
|
return false;
|
|
146
147
|
}
|
|
147
148
|
}
|
|
@@ -21,7 +21,7 @@ const getMaxLogPrefixesLength = () => {
|
|
|
21
21
|
function buildLog(prefix = undefined, options) {
|
|
22
22
|
const { colors = {}, log, useColors } = options ?? {};
|
|
23
23
|
const { info = 'yellow', error = 'red' } = colors;
|
|
24
|
-
const isInteractive = getProcess()?.stdout?.isTTY;
|
|
24
|
+
const isInteractive = getProcess()?.stdout?.isTTY ?? false;
|
|
25
25
|
const shouldUseColors = useColors !== false && isInteractive;
|
|
26
26
|
const pre = prefix ? `${prefix} ::` : undefined;
|
|
27
27
|
const transports = {
|
|
@@ -64,7 +64,7 @@ function buildLog(prefix = undefined, options) {
|
|
|
64
64
|
return t;
|
|
65
65
|
}
|
|
66
66
|
function write(chalkMethod, rawArgs, level) {
|
|
67
|
-
if (!shouldWrite(getProcess()?.env?.LOG_LEVEL ??
|
|
67
|
+
if (!shouldWrite(getProcess()?.env?.LOG_LEVEL ?? undefined, level)) {
|
|
68
68
|
return '';
|
|
69
69
|
}
|
|
70
70
|
const args = rawArgs.map((a) => a?.toString?.() ?? 'undefined');
|
|
@@ -109,8 +109,8 @@ function buildLog(prefix = undefined, options) {
|
|
|
109
109
|
: (console[logMethod] ?? console.log).bind(console));
|
|
110
110
|
let message = shouldUseColors === false
|
|
111
111
|
? `(${level})${prefix}`
|
|
112
|
-
: chalkMethod(...chalkArgs);
|
|
113
|
-
if (env.
|
|
112
|
+
: chalkMethod?.(...chalkArgs);
|
|
113
|
+
if (env.SHOULD_LOG_TIME_DELTAS !== 'false') {
|
|
114
114
|
const now = Date.now();
|
|
115
115
|
const diff = now - lastLogTimeMs;
|
|
116
116
|
lastLogTimeMs = now;
|
|
@@ -138,14 +138,14 @@ exports.stubLog = buildLog('STUB', {
|
|
|
138
138
|
useColors: false,
|
|
139
139
|
});
|
|
140
140
|
function shouldWrite(maxLogLevel, level) {
|
|
141
|
-
if (
|
|
142
|
-
if (
|
|
141
|
+
if (maxLogLevel) {
|
|
142
|
+
if (getProcess()?.env?.LOG_LEVEL == 'none') {
|
|
143
143
|
return false;
|
|
144
144
|
}
|
|
145
|
-
if (
|
|
145
|
+
if (getProcess()?.env?.LOG_LEVEL == 'error' && level !== 'ERROR') {
|
|
146
146
|
return false;
|
|
147
147
|
}
|
|
148
|
-
if (
|
|
148
|
+
if (getProcess()?.env?.LOG_LEVEL == 'warn' && level === 'INFO') {
|
|
149
149
|
return false;
|
|
150
150
|
}
|
|
151
151
|
}
|