dashcam 1.4.9-beta → 1.4.11-beta
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/lib/logger.js +15 -1
- package/lib/topProcesses.js +8 -12
- package/package.json +1 -1
package/lib/logger.js
CHANGED
|
@@ -26,9 +26,23 @@ const httpMeta = {
|
|
|
26
26
|
// Verbose level configuration
|
|
27
27
|
let isVerbose = false;
|
|
28
28
|
|
|
29
|
+
// Get version from package.json
|
|
30
|
+
let packageVersion = 'unknown';
|
|
31
|
+
try {
|
|
32
|
+
const { readFileSync } = await import('fs');
|
|
33
|
+
const { dirname, join } = await import('path');
|
|
34
|
+
const { fileURLToPath } = await import('url');
|
|
35
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
36
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
|
|
37
|
+
packageVersion = packageJson.version;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// Fallback to env variable if available
|
|
40
|
+
packageVersion = process.env.npm_package_version || 'unknown';
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
// Create custom format to include version and user info
|
|
30
44
|
const updateFormat = winston.format((info) => {
|
|
31
|
-
info.version =
|
|
45
|
+
info.version = packageVersion;
|
|
32
46
|
return info;
|
|
33
47
|
});
|
|
34
48
|
|
package/lib/topProcesses.js
CHANGED
|
@@ -193,13 +193,13 @@ async function getTopProcessesUnix(limit = 10) {
|
|
|
193
193
|
if (os.platform() === 'darwin') {
|
|
194
194
|
// macOS uses BSD ps - different syntax, no --sort option
|
|
195
195
|
// Use -r flag to sort by CPU usage
|
|
196
|
-
|
|
196
|
+
logger.info('Running macOS ps command');
|
|
197
197
|
const result = await execFileAsync('ps', [
|
|
198
198
|
'-Arco',
|
|
199
199
|
'pid,pcpu,pmem,comm'
|
|
200
200
|
], { encoding: 'utf8', timeout: 5000 });
|
|
201
201
|
stdout = result.stdout;
|
|
202
|
-
|
|
202
|
+
logger.info('macOS ps succeeded', { outputLength: stdout.length });
|
|
203
203
|
} else {
|
|
204
204
|
// Linux - try different variations in order of preference
|
|
205
205
|
const psVariations = [
|
|
@@ -216,18 +216,17 @@ async function getTopProcessesUnix(limit = 10) {
|
|
|
216
216
|
let psSuccess = false;
|
|
217
217
|
for (const variation of psVariations) {
|
|
218
218
|
try {
|
|
219
|
-
|
|
219
|
+
logger.info(`Trying ps variation: ${variation.name}`);
|
|
220
220
|
const result = await execFileAsync('ps', variation.args, {
|
|
221
221
|
encoding: 'utf8',
|
|
222
222
|
timeout: 5000
|
|
223
223
|
});
|
|
224
224
|
stdout = result.stdout;
|
|
225
|
-
|
|
226
|
-
logger.debug(`ps command succeeded: ${variation.name}`, { outputLength: stdout.length });
|
|
225
|
+
logger.info(`ps command succeeded: ${variation.name}`, { outputLength: stdout.length });
|
|
227
226
|
psSuccess = true;
|
|
228
227
|
break;
|
|
229
228
|
} catch (err) {
|
|
230
|
-
|
|
229
|
+
logger.warn(`ps variation failed: ${variation.name}`, { error: err.message });
|
|
231
230
|
// Try next variation
|
|
232
231
|
}
|
|
233
232
|
}
|
|
@@ -237,19 +236,16 @@ async function getTopProcessesUnix(limit = 10) {
|
|
|
237
236
|
}
|
|
238
237
|
}
|
|
239
238
|
|
|
240
|
-
|
|
239
|
+
logger.info('Parsing ps output');
|
|
241
240
|
const processes = parsePsOutput(stdout, limit);
|
|
242
|
-
|
|
243
|
-
logger.debug('Parsed processes from ps output', {
|
|
241
|
+
logger.info('Parsed processes from ps output', {
|
|
244
242
|
processCount: processes.length,
|
|
245
243
|
firstProcess: processes[0]
|
|
246
244
|
});
|
|
247
245
|
|
|
248
246
|
return processes;
|
|
249
247
|
} catch (error) {
|
|
250
|
-
|
|
251
|
-
console.error('[topProcesses] Error stack:', error.stack);
|
|
252
|
-
logger.warn('Failed to get top processes on Unix', {
|
|
248
|
+
logger.error('FATAL ERROR getting top processes on Unix', {
|
|
253
249
|
error: error.message,
|
|
254
250
|
stack: error.stack,
|
|
255
251
|
platform: os.platform()
|