From efeb44ebfc0ba79feb08de3caa17d33cecf925d0 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Fri, 14 Nov 2025 14:29:03 -0800 Subject: [PATCH 1/2] fix: cleaner startup logs --- README.md | 2 +- src/index.ts | 20 +++++++++++++++++--- src/utils/Logger.ts | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index da78777..add7271 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Installs Devtron into the Electron app. Refer to [Configuring an Electron App to | Option | Type | Default | Description | | ---------- | -------------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `logLevel` | `'debug' \| 'info' \| 'warn' \| 'error' \| 'none'` | `'debug'` | Sets the minimum log level for the logger. Messages below this level are ignored.

**Levels:**
• `debug` — logs: debug, info, warn, error
• `info` — logs: info, warn, error
• `warn` — logs: warn, error
• `error` — logs: error only
• `none` — disables all logging | +| `logLevel` | `'debug' \| 'info' \| 'warn' \| 'error' \| 'none'` | `'warn'` | Sets the minimum log level for the logger. Messages below this level are ignored.

**Levels:**
• `debug` — logs: debug, info, warn, error
• `info` — logs: info, warn, error
• `warn` — logs: warn, error
• `error` — logs: error only
• `none` — disables all logging | Examples: diff --git a/src/index.ts b/src/index.ts index 7de4c2a..85271f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,6 +27,12 @@ let isInstalled = false; let isInstalledToDefaultSession = false; let devtronSW: Electron.ServiceWorkerMain; +/** + * Count the number of IPC calls that were made before the service worker was ready. + * Used for logging purposes. + */ +let untrackedIpcCalls = 0; + const isPayloadWithUuid = (payload: any[]): boolean => { // If the first argument is an object with __uuid__devtron then it is a custom payload return ( @@ -67,7 +73,10 @@ function trackIpcEvent({ if (excludedIpcChannels.includes(channel)) return; if (!devtronSW) { - logger.warn('The service-worker for Devtron is not registered yet. Cannot track IPC event.'); + logger.info( + `The service worker for Devtron is not registered yet. Cannot track ${direction} IPC event for channel ${channel}.`, + ); + untrackedIpcCalls++; return; } @@ -415,7 +424,12 @@ async function install(options: InstallOptions = {}) { const extensionPath = path.resolve(serviceWorkerPreloadPath, '..', '..', 'extension'); devtron = await ses.extensions.loadExtension(extensionPath, { allowFileAccess: true }); await startServiceWorker(ses, devtron); - logger.info('Devtron loaded successfully'); + if (untrackedIpcCalls > 0) { + logger.warn( + `${untrackedIpcCalls} untracked IPC events were dispatched before the service worker was ready.`, + ); + } + logger.info('Devtron service worker loaded successfully'); } catch (error) { logger.error('Failed to load Devtron:', error); } @@ -440,7 +454,7 @@ async function getEvents(): Promise { } if (!devtronSW) { - logger.warn('Devtron service-worker is not registered yet. Cannot get IPC events.'); + logger.warn('Devtron service worker is not registered yet. Cannot get IPC events.'); return []; } diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index ef2b163..933a620 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -2,7 +2,7 @@ import type { LogLevelString } from '../types/shared'; import { LogLevel } from '../types/shared'; class Logger { - private currentLogLevel = LogLevel.debug; + private currentLogLevel = LogLevel.warn; setLogLevel(level: LogLevelString) { if (LogLevel[level] === undefined) { From 069b4ae1f6b1f35056d2ae5b2b1638b6f2ff465b Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Mon, 17 Nov 2025 09:47:35 -0800 Subject: [PATCH 2/2] fix linting issue --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 204d4e2..7efb9ef 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ Installs Devtron into the Electron app. Refer to [Configuring an Electron App to #### `Options` -| Option | Type | Default | Description | -| ---------- | -------------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Option | Type | Default | Description | +| ---------- | -------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `logLevel` | `'debug' \| 'info' \| 'warn' \| 'error' \| 'none'` | `'warn'` | Sets the minimum log level for the logger. Messages below this level are ignored.

**Levels:**
• `debug` — logs: debug, info, warn, error
• `info` — logs: info, warn, error
• `warn` — logs: warn, error
• `error` — logs: error only
• `none` — disables all logging | Examples: