Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix logging inside worker

Abhinavca7cbf08b748
diff --git a/packages/shared/electron/service.ts b/packages/shared/electron/service.ts
index abbd031954..dfa63eaec3 100644
--- a/packages/shared/electron/service.ts
+++ b/packages/shared/electron/service.ts
@@ -16,6 +16,7 @@ export interface LimitedElectronAPIs
| 'deleteDiskCache'
| 'getSentryUserID'
| 'convertToJPEG'
+ | 'logToDisk'
> {}
class WorkerSafeElectronServiceImpl implements LimitedElectronAPIs {
@@ -66,6 +67,10 @@ class WorkerSafeElectronServiceImpl implements LimitedElectronAPIs {
await this.ready;
return this.proxiedElectron.convertToJPEG(inputFileData, filename);
}
+ async logToDisk(message: string) {
+ await this.ready;
+ return this.proxiedElectron.logToDisk(message);
+ }
}
export const WorkerSafeElectronService = new WorkerSafeElectronServiceImpl();
diff --git a/packages/shared/electron/worker/client.ts b/packages/shared/electron/worker/client.ts
index f16a9e0e54..c1e09b8888 100644
--- a/packages/shared/electron/worker/client.ts
+++ b/packages/shared/electron/worker/client.ts
@@ -14,6 +14,7 @@ export interface ProxiedLimitedElectronAPIs {
inputFileData: Uint8Array,
filename: string
) => Promise<Uint8Array>;
+ logToDisk: (message: string) => void;
}
export interface ProxiedWorkerLimitedCache {
match: (
@@ -51,6 +52,9 @@ export class WorkerSafeElectronClient implements ProxiedLimitedElectronAPIs {
): Promise<Uint8Array> {
return await ElectronAPIs.convertToJPEG(inputFileData, filename);
}
+ logToDisk(message: string) {
+ return ElectronAPIs.logToDisk(message);
+ }
}
function transformMatch(
diff --git a/packages/shared/logging/index.ts b/packages/shared/logging/index.ts
index e8ddb61197..9f257cb3a0 100644
--- a/packages/shared/logging/index.ts
+++ b/packages/shared/logging/index.ts
@@ -1,9 +1,9 @@
import isElectron from 'is-electron';
-import ElectronAPIs from '@ente/shared/electron';
import { logError } from '@ente/shared/sentry';
import { getAppEnv } from '../apps/env';
import { APP_ENV } from '../apps/constants';
import { formatLog, logWeb } from './web';
+import { WorkerSafeElectronService } from '../electron/service';
export const MAX_LOG_SIZE = 5 * 1024 * 1024; // 5MB
export const MAX_LOG_LINES = 1000;
@@ -18,7 +18,7 @@ export function addLogLine(
console.log(completeLog);
}
if (isElectron()) {
- ElectronAPIs.logToDisk(completeLog);
+ WorkerSafeElectronService.logToDisk(completeLog);
} else {
logWeb(completeLog);
}