@luquimbo/bi-superpowers 3.1.1 → 3.2.0
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.claude-plugin/skill-manifest.json +1 -1
- package/.plugin/plugin.json +1 -1
- package/bin/build-plugin.js +6 -6
- package/bin/cli.js +169 -310
- package/bin/commands/install.js +87 -70
- package/bin/lib/agents.js +19 -0
- package/bin/lib/mcp-config.js +23 -4
- package/desktop-extension/manifest.json +4 -11
- package/desktop-extension/server.js +34 -25
- package/package.json +3 -9
- package/skills/pbi-connect/SKILL.md +1 -1
- package/skills/project-kickoff/SKILL.md +1 -1
- package/bin/commands/add.js +0 -533
- package/bin/commands/add.test.js +0 -77
- package/bin/commands/changelog.js +0 -443
- package/bin/commands/pull.js +0 -287
- package/bin/commands/pull.test.js +0 -36
- package/bin/commands/push.js +0 -231
- package/bin/commands/push.test.js +0 -14
- package/bin/commands/search.js +0 -344
- package/bin/commands/search.test.js +0 -115
- package/bin/commands/setup.js +0 -545
- package/bin/commands/setup.test.js +0 -46
- package/bin/commands/sync-profile.js +0 -405
- package/bin/commands/sync-profile.test.js +0 -14
- package/bin/commands/sync-source.js +0 -418
- package/bin/commands/sync-source.test.js +0 -14
- package/bin/utils/errors.js +0 -159
- package/bin/utils/git.js +0 -298
- package/bin/utils/logger.js +0 -142
- package/bin/utils/pbix.js +0 -305
- package/bin/utils/pbix.test.js +0 -37
- package/bin/utils/profiles.js +0 -312
- package/bin/utils/projects.js +0 -169
- package/bin/utils/readline.js +0 -206
- package/bin/utils/readline.test.js +0 -47
- package/docs/openrouter-free-models.md +0 -92
- package/library/examples/README.md +0 -151
- package/library/examples/finance-reporting/README.md +0 -351
- package/library/examples/finance-reporting/data-model.md +0 -267
- package/library/examples/finance-reporting/measures.dax +0 -557
- package/library/examples/hr-analytics/README.md +0 -371
- package/library/examples/hr-analytics/data-model.md +0 -315
- package/library/examples/hr-analytics/measures.dax +0 -460
- package/library/examples/marketing-analytics/README.md +0 -37
- package/library/examples/marketing-analytics/data-model.md +0 -62
- package/library/examples/marketing-analytics/measures.dax +0 -110
- package/library/examples/retail-analytics/README.md +0 -439
- package/library/examples/retail-analytics/data-model.md +0 -288
- package/library/examples/retail-analytics/measures.dax +0 -481
- package/library/examples/supply-chain/README.md +0 -37
- package/library/examples/supply-chain/data-model.md +0 -69
- package/library/examples/supply-chain/measures.dax +0 -77
- package/library/examples/udf-library/README.md +0 -228
- package/library/examples/udf-library/functions.dax +0 -571
- package/library/snippets/dax/README.md +0 -292
- package/library/snippets/dax/business-domains.md +0 -576
- package/library/snippets/dax/calculate-patterns.md +0 -276
- package/library/snippets/dax/calculation-groups.md +0 -489
- package/library/snippets/dax/error-handling.md +0 -495
- package/library/snippets/dax/iterators-and-aggregations.md +0 -474
- package/library/snippets/dax/kpis-and-metrics.md +0 -293
- package/library/snippets/dax/rankings-and-topn.md +0 -235
- package/library/snippets/dax/security-patterns.md +0 -413
- package/library/snippets/dax/text-and-formatting.md +0 -316
- package/library/snippets/dax/time-intelligence.md +0 -196
- package/library/snippets/dax/user-defined-functions.md +0 -477
- package/library/snippets/dax/virtual-tables.md +0 -546
- package/library/snippets/excel-formulas/README.md +0 -84
- package/library/snippets/excel-formulas/aggregations.md +0 -330
- package/library/snippets/excel-formulas/dates-and-times.md +0 -361
- package/library/snippets/excel-formulas/dynamic-arrays.md +0 -314
- package/library/snippets/excel-formulas/lookups.md +0 -169
- package/library/snippets/excel-formulas/text-functions.md +0 -363
- package/library/snippets/governance/naming-conventions.md +0 -97
- package/library/snippets/governance/review-checklists.md +0 -107
- package/library/snippets/power-query/README.md +0 -389
- package/library/snippets/power-query/api-integration.md +0 -707
- package/library/snippets/power-query/connections.md +0 -434
- package/library/snippets/power-query/data-cleaning.md +0 -298
- package/library/snippets/power-query/error-handling.md +0 -526
- package/library/snippets/power-query/parameters.md +0 -350
- package/library/snippets/power-query/performance.md +0 -506
- package/library/snippets/power-query/transformations.md +0 -330
- package/library/snippets/report-design/accessibility.md +0 -78
- package/library/snippets/report-design/chart-selection.md +0 -54
- package/library/snippets/report-design/layout-patterns.md +0 -87
- package/library/templates/data-models/README.md +0 -93
- package/library/templates/data-models/finance-model.md +0 -627
- package/library/templates/data-models/retail-star-schema.md +0 -473
- package/library/templates/excel/README.md +0 -83
- package/library/templates/excel/budget-tracker.md +0 -432
- package/library/templates/excel/data-entry-form.md +0 -533
- package/library/templates/power-bi/README.md +0 -72
- package/library/templates/power-bi/finance-report.md +0 -449
- package/library/templates/power-bi/kpi-scorecard.md +0 -461
- package/library/templates/power-bi/sales-dashboard.md +0 -281
- package/library/themes/excel/README.md +0 -436
- package/library/themes/power-bi/README.md +0 -271
- package/library/themes/power-bi/accessible.json +0 -307
- package/library/themes/power-bi/bi-superpowers-default.json +0 -858
- package/library/themes/power-bi/corporate-blue.json +0 -291
- package/library/themes/power-bi/dark-mode.json +0 -291
- package/library/themes/power-bi/minimal.json +0 -292
- package/library/themes/power-bi/print-friendly.json +0 -309
package/bin/utils/git.js
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Git Utilities for BI Agent Superpowers
|
|
3
|
-
* =======================================
|
|
4
|
-
*
|
|
5
|
-
* Provides Git operations for the multi-project repo system.
|
|
6
|
-
* Uses simple-git for robust cross-platform Git operations.
|
|
7
|
-
*
|
|
8
|
-
* @module utils/git
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const { execSync, spawnSync } = require('child_process');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Check if Git is installed on the system
|
|
15
|
-
* @returns {boolean} True if Git is available
|
|
16
|
-
*/
|
|
17
|
-
function isGitInstalled() {
|
|
18
|
-
try {
|
|
19
|
-
execSync('git --version', { stdio: 'pipe' });
|
|
20
|
-
return true;
|
|
21
|
-
} catch (e) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Check if a directory is a Git repository
|
|
28
|
-
* @param {string} dir - Directory path to check
|
|
29
|
-
* @returns {boolean} True if directory is a Git repo
|
|
30
|
-
*/
|
|
31
|
-
function isGitRepo(dir) {
|
|
32
|
-
try {
|
|
33
|
-
const result = spawnSync('git', ['rev-parse', '--git-dir'], {
|
|
34
|
-
cwd: dir,
|
|
35
|
-
stdio: 'pipe',
|
|
36
|
-
});
|
|
37
|
-
return result.status === 0;
|
|
38
|
-
} catch (e) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Initialize a new Git repository
|
|
45
|
-
* @param {string} dir - Directory to initialize
|
|
46
|
-
* @returns {boolean} True if successful
|
|
47
|
-
*/
|
|
48
|
-
function initRepo(dir) {
|
|
49
|
-
try {
|
|
50
|
-
const result = spawnSync('git', ['init'], {
|
|
51
|
-
cwd: dir,
|
|
52
|
-
stdio: 'pipe',
|
|
53
|
-
});
|
|
54
|
-
return result.status === 0;
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Stage files in Git
|
|
62
|
-
* @param {string} dir - Repository directory
|
|
63
|
-
* @param {string|string[]} files - Files to stage (use '.' for all)
|
|
64
|
-
* @returns {boolean} True if successful
|
|
65
|
-
*/
|
|
66
|
-
function stageFiles(dir, files = '.') {
|
|
67
|
-
try {
|
|
68
|
-
const fileArgs = Array.isArray(files) ? files : [files];
|
|
69
|
-
const result = spawnSync('git', ['add', ...fileArgs], {
|
|
70
|
-
cwd: dir,
|
|
71
|
-
stdio: 'pipe',
|
|
72
|
-
});
|
|
73
|
-
return result.status === 0;
|
|
74
|
-
} catch (e) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Create a Git commit
|
|
81
|
-
* @param {string} dir - Repository directory
|
|
82
|
-
* @param {string} message - Commit message
|
|
83
|
-
* @returns {boolean} True if successful
|
|
84
|
-
*/
|
|
85
|
-
function commit(dir, message) {
|
|
86
|
-
try {
|
|
87
|
-
const result = spawnSync('git', ['commit', '-m', message], {
|
|
88
|
-
cwd: dir,
|
|
89
|
-
stdio: 'pipe',
|
|
90
|
-
});
|
|
91
|
-
return result.status === 0;
|
|
92
|
-
} catch (e) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get the current branch name
|
|
99
|
-
* @param {string} dir - Repository directory
|
|
100
|
-
* @returns {string|null} Branch name or null if not in a repo
|
|
101
|
-
*/
|
|
102
|
-
function getCurrentBranch(dir) {
|
|
103
|
-
try {
|
|
104
|
-
const result = spawnSync('git', ['branch', '--show-current'], {
|
|
105
|
-
cwd: dir,
|
|
106
|
-
stdio: 'pipe',
|
|
107
|
-
});
|
|
108
|
-
if (result.status === 0) {
|
|
109
|
-
return result.stdout.toString().trim();
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
} catch (e) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Get the status of the repository
|
|
119
|
-
* @param {string} dir - Repository directory
|
|
120
|
-
* @returns {Object} Status object with modified, staged, untracked files
|
|
121
|
-
*/
|
|
122
|
-
function getStatus(dir) {
|
|
123
|
-
try {
|
|
124
|
-
const result = spawnSync('git', ['status', '--porcelain'], {
|
|
125
|
-
cwd: dir,
|
|
126
|
-
stdio: 'pipe',
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
if (result.status !== 0) {
|
|
130
|
-
return { modified: [], staged: [], untracked: [] };
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const lines = result.stdout.toString().trim().split('\n').filter(Boolean);
|
|
134
|
-
const status = { modified: [], staged: [], untracked: [] };
|
|
135
|
-
|
|
136
|
-
for (const line of lines) {
|
|
137
|
-
const code = line.substring(0, 2);
|
|
138
|
-
const file = line.substring(3);
|
|
139
|
-
|
|
140
|
-
if (code.includes('?')) {
|
|
141
|
-
status.untracked.push(file);
|
|
142
|
-
} else if (code[0] !== ' ') {
|
|
143
|
-
status.staged.push(file);
|
|
144
|
-
} else if (code[1] !== ' ') {
|
|
145
|
-
status.modified.push(file);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return status;
|
|
150
|
-
} catch (e) {
|
|
151
|
-
return { modified: [], staged: [], untracked: [] };
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Get commit log
|
|
157
|
-
* @param {string} dir - Repository directory
|
|
158
|
-
* @param {number} count - Number of commits to retrieve
|
|
159
|
-
* @returns {Array} Array of commit objects
|
|
160
|
-
*/
|
|
161
|
-
function getLog(dir, count = 10) {
|
|
162
|
-
try {
|
|
163
|
-
const result = spawnSync(
|
|
164
|
-
'git',
|
|
165
|
-
['log', `--max-count=${count}`, '--pretty=format:%H|%s|%ai|%an'],
|
|
166
|
-
{
|
|
167
|
-
cwd: dir,
|
|
168
|
-
stdio: 'pipe',
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
if (result.status !== 0) {
|
|
173
|
-
return [];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const lines = result.stdout.toString().trim().split('\n').filter(Boolean);
|
|
177
|
-
return lines.map((line) => {
|
|
178
|
-
const [hash, subject, date, author] = line.split('|');
|
|
179
|
-
return { hash, subject, date, author };
|
|
180
|
-
});
|
|
181
|
-
} catch (e) {
|
|
182
|
-
return [];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Check if there are uncommitted changes
|
|
188
|
-
* @param {string} dir - Repository directory
|
|
189
|
-
* @returns {boolean} True if there are uncommitted changes
|
|
190
|
-
*/
|
|
191
|
-
function hasUncommittedChanges(dir) {
|
|
192
|
-
const status = getStatus(dir);
|
|
193
|
-
return status.modified.length > 0 || status.staged.length > 0 || status.untracked.length > 0;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Checkout a specific commit or branch
|
|
198
|
-
* @param {string} dir - Repository directory
|
|
199
|
-
* @param {string} ref - Reference to checkout (commit hash, branch, tag)
|
|
200
|
-
* @returns {boolean} True if successful
|
|
201
|
-
*/
|
|
202
|
-
function checkout(dir, ref) {
|
|
203
|
-
try {
|
|
204
|
-
const result = spawnSync('git', ['checkout', ref], {
|
|
205
|
-
cwd: dir,
|
|
206
|
-
stdio: 'pipe',
|
|
207
|
-
});
|
|
208
|
-
return result.status === 0;
|
|
209
|
-
} catch (e) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Get diff between two commits or current changes
|
|
216
|
-
* @param {string} dir - Repository directory
|
|
217
|
-
* @param {string} from - Starting reference (optional)
|
|
218
|
-
* @param {string} to - Ending reference (optional)
|
|
219
|
-
* @returns {string} Diff output
|
|
220
|
-
*/
|
|
221
|
-
function getDiff(dir, from = null, to = null) {
|
|
222
|
-
try {
|
|
223
|
-
const args = ['diff'];
|
|
224
|
-
if (from) args.push(from);
|
|
225
|
-
if (to) args.push(to);
|
|
226
|
-
|
|
227
|
-
const result = spawnSync('git', args, {
|
|
228
|
-
cwd: dir,
|
|
229
|
-
stdio: 'pipe',
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
return result.stdout.toString();
|
|
233
|
-
} catch (e) {
|
|
234
|
-
return '';
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Execute a raw Git command and return output
|
|
240
|
-
* @param {string} dir - Repository directory
|
|
241
|
-
* @param {string[]} args - Git command arguments
|
|
242
|
-
* @returns {string|null} Command output or null on failure
|
|
243
|
-
*/
|
|
244
|
-
function execGitCommand(dir, args) {
|
|
245
|
-
try {
|
|
246
|
-
const result = spawnSync('git', args, {
|
|
247
|
-
cwd: dir,
|
|
248
|
-
stdio: 'pipe',
|
|
249
|
-
maxBuffer: 1024 * 1024 * 10, // 10MB buffer for large outputs
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
if (result.status === 0) {
|
|
253
|
-
return result.stdout.toString();
|
|
254
|
-
}
|
|
255
|
-
return null;
|
|
256
|
-
} catch (e) {
|
|
257
|
-
return null;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Get file modification date from last commit
|
|
263
|
-
* @param {string} dir - Repository directory
|
|
264
|
-
* @param {string} filePath - Path to file relative to repo root
|
|
265
|
-
* @returns {Date|null} Last modification date or null
|
|
266
|
-
*/
|
|
267
|
-
function getFileLastModified(dir, filePath) {
|
|
268
|
-
try {
|
|
269
|
-
const result = spawnSync('git', ['log', '-1', '--format=%ai', '--', filePath], {
|
|
270
|
-
cwd: dir,
|
|
271
|
-
stdio: 'pipe',
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
if (result.status === 0) {
|
|
275
|
-
const dateStr = result.stdout.toString().trim();
|
|
276
|
-
return dateStr ? new Date(dateStr) : null;
|
|
277
|
-
}
|
|
278
|
-
return null;
|
|
279
|
-
} catch (e) {
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
module.exports = {
|
|
285
|
-
isGitInstalled,
|
|
286
|
-
isGitRepo,
|
|
287
|
-
initRepo,
|
|
288
|
-
stageFiles,
|
|
289
|
-
commit,
|
|
290
|
-
getCurrentBranch,
|
|
291
|
-
getStatus,
|
|
292
|
-
getLog,
|
|
293
|
-
hasUncommittedChanges,
|
|
294
|
-
checkout,
|
|
295
|
-
getDiff,
|
|
296
|
-
execGitCommand,
|
|
297
|
-
getFileLastModified,
|
|
298
|
-
};
|
package/bin/utils/logger.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logger Utility
|
|
3
|
-
* ===============
|
|
4
|
-
*
|
|
5
|
-
* Standardized logging for the CLI with log levels.
|
|
6
|
-
* Respects LOG_LEVEL environment variable.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* const logger = require('./utils/logger');
|
|
10
|
-
* logger.debug('Debug message', { context: 'optional' });
|
|
11
|
-
* logger.info('Info message');
|
|
12
|
-
* logger.warn('Warning message');
|
|
13
|
-
* logger.error('Error message');
|
|
14
|
-
*
|
|
15
|
-
* Environment:
|
|
16
|
-
* LOG_LEVEL=debug|info|warn|error (default: info)
|
|
17
|
-
* DEBUG=true (shorthand for LOG_LEVEL=debug)
|
|
18
|
-
*
|
|
19
|
-
* @module utils/logger
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const LOG_LEVELS = {
|
|
23
|
-
debug: 0,
|
|
24
|
-
info: 1,
|
|
25
|
-
warn: 2,
|
|
26
|
-
error: 3,
|
|
27
|
-
silent: 4,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Get current log level from environment
|
|
32
|
-
* @returns {string} Current log level
|
|
33
|
-
*/
|
|
34
|
-
function getCurrentLevel() {
|
|
35
|
-
if (process.env.DEBUG === 'true') {
|
|
36
|
-
return 'debug';
|
|
37
|
-
}
|
|
38
|
-
return process.env.LOG_LEVEL || 'info';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Check if a log level should be shown
|
|
43
|
-
* @param {string} level - Level to check
|
|
44
|
-
* @returns {boolean} Whether to show this level
|
|
45
|
-
*/
|
|
46
|
-
function shouldLog(level) {
|
|
47
|
-
const currentLevel = getCurrentLevel();
|
|
48
|
-
return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Format a log message with optional context
|
|
53
|
-
* @param {string} prefix - Log level prefix
|
|
54
|
-
* @param {string} message - Log message
|
|
55
|
-
* @param {Object|null} context - Optional context object
|
|
56
|
-
* @returns {string} Formatted message
|
|
57
|
-
*/
|
|
58
|
-
function formatMessage(prefix, message, context) {
|
|
59
|
-
let formatted = `[${prefix}] ${message}`;
|
|
60
|
-
if (context !== null && context !== undefined) {
|
|
61
|
-
if (typeof context === 'object') {
|
|
62
|
-
formatted += ` ${JSON.stringify(context)}`;
|
|
63
|
-
} else {
|
|
64
|
-
formatted += ` ${context}`;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return formatted;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Debug level logging
|
|
72
|
-
* Only shown when LOG_LEVEL=debug or DEBUG=true
|
|
73
|
-
* @param {string} message - Log message
|
|
74
|
-
* @param {Object|null} context - Optional context
|
|
75
|
-
*/
|
|
76
|
-
function debug(message, context = null) {
|
|
77
|
-
if (shouldLog('debug')) {
|
|
78
|
-
console.log(formatMessage('DEBUG', message, context));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Info level logging
|
|
84
|
-
* Standard informational messages
|
|
85
|
-
* @param {string} message - Log message
|
|
86
|
-
* @param {Object|null} context - Optional context
|
|
87
|
-
*/
|
|
88
|
-
function info(message, context = null) {
|
|
89
|
-
if (shouldLog('info')) {
|
|
90
|
-
console.log(formatMessage('INFO', message, context));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Warning level logging
|
|
96
|
-
* Non-critical issues that should be noticed
|
|
97
|
-
* @param {string} message - Log message
|
|
98
|
-
* @param {Object|null} context - Optional context
|
|
99
|
-
*/
|
|
100
|
-
function warn(message, context = null) {
|
|
101
|
-
if (shouldLog('warn')) {
|
|
102
|
-
console.warn(formatMessage('WARN', message, context));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Error level logging
|
|
108
|
-
* Critical errors that affect operation
|
|
109
|
-
* @param {string} message - Log message
|
|
110
|
-
* @param {Object|null} context - Optional context
|
|
111
|
-
*/
|
|
112
|
-
function error(message, context = null) {
|
|
113
|
-
if (shouldLog('error')) {
|
|
114
|
-
console.error(formatMessage('ERROR', message, context));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Create a child logger with a prefix
|
|
120
|
-
* Useful for module-specific logging
|
|
121
|
-
* @param {string} prefix - Prefix for all messages
|
|
122
|
-
* @returns {Object} Logger instance with prefix
|
|
123
|
-
*/
|
|
124
|
-
function createLogger(prefix) {
|
|
125
|
-
return {
|
|
126
|
-
debug: (msg, ctx) => debug(`[${prefix}] ${msg}`, ctx),
|
|
127
|
-
info: (msg, ctx) => info(`[${prefix}] ${msg}`, ctx),
|
|
128
|
-
warn: (msg, ctx) => warn(`[${prefix}] ${msg}`, ctx),
|
|
129
|
-
error: (msg, ctx) => error(`[${prefix}] ${msg}`, ctx),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
module.exports = {
|
|
134
|
-
LOG_LEVELS,
|
|
135
|
-
debug,
|
|
136
|
-
info,
|
|
137
|
-
warn,
|
|
138
|
-
error,
|
|
139
|
-
createLogger,
|
|
140
|
-
getCurrentLevel,
|
|
141
|
-
shouldLog,
|
|
142
|
-
};
|