@sprucelabs/spruce-skill-utils 31.2.9 → 31.2.11

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.
@@ -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;
62
- if (shouldNotWrite(level)) {
62
+ if (!shouldWrite(process.env.LOG_LEVEL, 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'; });
@@ -75,7 +75,7 @@ export default function buildLog(prefix = undefined, options) {
75
75
  }
76
76
  chalkArgs = [builtPrefix, ...chalkArgs];
77
77
  }
78
- const prefix = `${builtPrefix ? ` ${builtPrefix}` : ''}`;
78
+ const prefix = builtPrefix ? ` ${builtPrefix}` : '';
79
79
  let transports = getTransports(level);
80
80
  if (transports.length > 0) {
81
81
  for (const transport of transports) {
@@ -133,13 +133,17 @@ export const stubLog = buildLog('STUB', {
133
133
  log: () => { },
134
134
  useColors: false,
135
135
  });
136
- const logLevels = ['INFO', 'WARN', 'ERROR', 'NONE'];
137
- function shouldNotWrite(level) {
138
- var _a, _b, _c, _d;
139
- const requestedLogLevelStrength = logLevels.indexOf(level);
140
- const allowedLogLevelStrength = logLevels.indexOf((_d = (_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 ? void 0 : _c.toUpperCase()) !== null && _d !== void 0 ? _d : 'INFO');
141
- if (allowedLogLevelStrength === -1) {
142
- return false;
136
+ function shouldWrite(maxLogLevel, level) {
137
+ if (process.env.LOG_LEVEL) {
138
+ if (process.env.LOG_LEVEL == 'none') {
139
+ return false;
140
+ }
141
+ if (process.env.LOG_LEVEL == 'error' && level !== 'ERROR') {
142
+ return false;
143
+ }
144
+ if (process.env.LOG_LEVEL == 'warn' && level === 'INFO') {
145
+ return false;
146
+ }
143
147
  }
144
- return requestedLogLevelStrength < allowedLogLevelStrength;
148
+ return true;
145
149
  }
@@ -64,7 +64,7 @@ function buildLog(prefix = undefined, options) {
64
64
  return t;
65
65
  }
66
66
  function write(chalkMethod, rawArgs, level) {
67
- if (shouldNotWrite(level)) {
67
+ if (!shouldWrite(process.env.LOG_LEVEL, level)) {
68
68
  return '';
69
69
  }
70
70
  const args = rawArgs.map((a) => a?.toString?.() ?? 'undefined');
@@ -80,7 +80,7 @@ function buildLog(prefix = undefined, options) {
80
80
  }
81
81
  chalkArgs = [builtPrefix, ...chalkArgs];
82
82
  }
83
- const prefix = `${builtPrefix ? ` ${builtPrefix}` : ''}`;
83
+ const prefix = builtPrefix ? ` ${builtPrefix}` : '';
84
84
  let transports = getTransports(level);
85
85
  if (transports.length > 0) {
86
86
  for (const transport of transports) {
@@ -137,12 +137,17 @@ exports.stubLog = buildLog('STUB', {
137
137
  log: () => { },
138
138
  useColors: false,
139
139
  });
140
- const logLevels = ['INFO', 'WARN', 'ERROR', 'NONE'];
141
- function shouldNotWrite(level) {
142
- const requestedLogLevelStrength = logLevels.indexOf(level);
143
- const allowedLogLevelStrength = logLevels.indexOf(getProcess()?.env?.LOG_LEVEL?.toUpperCase() ?? 'INFO');
144
- if (allowedLogLevelStrength === -1) {
145
- return false;
140
+ function shouldWrite(maxLogLevel, level) {
141
+ if (process.env.LOG_LEVEL) {
142
+ if (process.env.LOG_LEVEL == 'none') {
143
+ return false;
144
+ }
145
+ if (process.env.LOG_LEVEL == 'error' && level !== 'ERROR') {
146
+ return false;
147
+ }
148
+ if (process.env.LOG_LEVEL == 'warn' && level === 'INFO') {
149
+ return false;
150
+ }
146
151
  }
147
- return requestedLogLevelStrength < allowedLogLevelStrength;
152
+ return true;
148
153
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "31.2.9",
6
+ "version": "31.2.11",
7
7
  "skill": {
8
8
  "namespace": "skill-utils",
9
9
  "upgradeIgnoreList": [
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@sprucelabs/globby": "^2.0.501",
62
- "@sprucelabs/schema": "^31.0.15",
62
+ "@sprucelabs/schema": "^31.0.16",
63
63
  "chalk": "^4.1.2",
64
64
  "dotenv": "^16.4.7",
65
65
  "fs-extra": "^11.2.0",
@@ -74,11 +74,11 @@
74
74
  "@sprucelabs/resolve-path-aliases": "^2.0.526",
75
75
  "@sprucelabs/semantic-release": "^5.0.2",
76
76
  "@sprucelabs/test": "^9.0.67",
77
- "@sprucelabs/test-utils": "^5.1.542",
77
+ "@sprucelabs/test-utils": "^5.1.543",
78
78
  "@types/fs-extra": "^11.0.4",
79
79
  "@types/inflection": "^1.13.2",
80
80
  "@types/lodash": "^4.17.14",
81
- "@types/node": "^22.10.5",
81
+ "@types/node": "^22.10.6",
82
82
  "@types/uuid": "^10.0.0",
83
83
  "chokidar-cli": "^3.0.0",
84
84
  "eslint": "^9.18.0",