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 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 = process.env.npm_package_version;
45
+ info.version = packageVersion;
32
46
  return info;
33
47
  });
34
48
 
@@ -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
- console.log('[topProcesses] Running macOS ps command');
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
- console.log('[topProcesses] macOS ps succeeded, output length:', stdout.length);
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
- console.log(`[topProcesses] Trying: ${variation.name}`);
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
- console.log(`[topProcesses] ${variation.name} succeeded, output length:`, stdout.length);
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
- console.log(`[topProcesses] ${variation.name} failed:`, err.message);
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
- console.log('[topProcesses] Parsing ps output...');
239
+ logger.info('Parsing ps output');
241
240
  const processes = parsePsOutput(stdout, limit);
242
- console.log('[topProcesses] Parsed', processes.length, 'processes');
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
- console.error('[topProcesses] FATAL ERROR getting top processes:', error.message);
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()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.4.9-beta",
3
+ "version": "1.4.11-beta",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/dashcam.js",
6
6
  "bin": {