diff --git a/README.md b/README.md
index 0cdc6bb..7efb9ef 100644
--- a/README.md
+++ b/README.md
@@ -55,9 +55,9 @@ Installs Devtron into the Electron app. Refer to [Configuring an Electron App to
#### `Options`
-| 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 |
+| 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:
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) {