From 4502162a36eb233fba8c4fa8d6f4260f1a70feab Mon Sep 17 00:00:00 2001 From: evlist Date: Sun, 12 Feb 2023 14:10:56 +0100 Subject: [PATCH] Removing a few console.log... --- src/db-admin/health-legacy.ts | 6 ++--- src/db/change-handler.ts | 40 ++++++++++++++++---------------- src/workers/dispatcher-main.ts | 34 +++++++++++++-------------- src/workers/dispatcher-worker.ts | 28 +++++++++++----------- 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/db-admin/health-legacy.ts b/src/db-admin/health-legacy.ts index eade03a..111654d 100644 --- a/src/db-admin/health-legacy.ts +++ b/src/db-admin/health-legacy.ts @@ -77,7 +77,7 @@ export const watchDbLegacy = async () => { globalThis.sync .on('change', function (info) { // handle change - console.log({ caller: 'Sync / change', info }); + // console.log({ caller: 'Sync / change', info }); if (info.direction === 'push') { setSyncState({ ...syncState(), lastSeq: info.change.last_seq }); } @@ -85,12 +85,12 @@ export const watchDbLegacy = async () => { .on('paused', function (err) { // replication paused (e.g. replication up to date, user went offline) setSyncState({ ...syncState(), paused: true }); - console.log({ caller: 'Sync / paused', err }); + // console.log({ caller: 'Sync / paused', err }); }) .on('active', function () { // replicate resumed (e.g. new changes replicating, user went back online) setSyncState({ ...syncState(), paused: false }); - console.log({ caller: 'Sync / active' }); + // console.log({ caller: 'Sync / active' }); }) .on('denied', function (err) { // a document failed to replicate (e.g. due to permissions) diff --git a/src/db/change-handler.ts b/src/db/change-handler.ts index af0c834..b17a682 100644 --- a/src/db/change-handler.ts +++ b/src/db/change-handler.ts @@ -43,7 +43,7 @@ for (const property in methods) { } const changeHandler = async (change: any) => { - console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches }); + // console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches }); const { id } = change; if (!globalThis.watches) { globalThis.watches = new Map(); @@ -55,22 +55,22 @@ const changeHandler = async (change: any) => { tokens.splice(-1); } const parentId = tokens.join('/'); - console.log({ - caller: 'ChangeHandler', - change, - watches: globalThis.watches, - parentId, - }); + // console.log({ + // caller: 'ChangeHandler', + // change, + // watches: globalThis.watches, + // parentId, + // }); if (parentId === 'gpx') { const gpxes = await getAllGpxes(); - console.log({ caller: 'changeHandler / gpxes', gpxes, id }); + // console.log({ caller: 'changeHandler / gpxes', gpxes, id }); if (!gpxes.includes(id)) { await put( parentId, `idx-${parentId}`, (doc) => { - console.log({ caller: 'changeHandler / gpxes', doc }); + // console.log({ caller: 'changeHandler / gpxes', doc }); doc.push(id); doc.reverse().sort().reverse(); return doc; @@ -89,23 +89,23 @@ const changeHandler = async (change: any) => { export default changeHandler; export const getAndWatch = async (params: any) => { - console.log({ - caller: 'ChangeHandler / getAndWatch', - params, - watches: globalThis.watches, - }); + // console.log({ + // caller: 'ChangeHandler / getAndWatch', + // params, + // watches: globalThis.watches, + // }); const { method, _dispatchId, id, ...otherParams } = params; if (!globalThis.watches) { globalThis.watches = new Map(); } globalThis.watches.set(id, params); const returnValue = await methods[method](params); - console.log({ - caller: 'ChangeHandler / getAndWatch', - params, - returnValue, - watches: globalThis.watches, - }); + // console.log({ + // caller: 'ChangeHandler / getAndWatch', + // params, + // returnValue, + // watches: globalThis.watches, + // }); return returnValue; }; diff --git a/src/workers/dispatcher-main.ts b/src/workers/dispatcher-main.ts index a290496..b20d320 100644 --- a/src/workers/dispatcher-main.ts +++ b/src/workers/dispatcher-main.ts @@ -19,12 +19,12 @@ export const init = () => { worker.onmessage = (event: any) => { const { id, payload } = event.data; - console.log({ - caller: 'dispatcher-main / message received', - id, - payload, - dispatcherQueue: JSON.parse(JSON.stringify(dispatcherQueue)), - }); + // console.log({ + // caller: 'dispatcher-main / message received', + // id, + // payload, + // dispatcherQueue: JSON.parse(JSON.stringify(dispatcherQueue)), + // }); dispatcherQueue.queue.get(id).callBack(null, payload, id); if (!dispatcherQueue.queue.get(id).live) { cancelDispatch(id); @@ -36,11 +36,11 @@ const [watchDbStatus] = createWorkerSignal({ provider: 'watchDb', }); const dbReady = () => { - console.log({ - caller: 'dispatcher-main / waiting', - dbStatus: watchDbStatus(), - dbReady: watchDbStatus()?.opened, - }); + // console.log({ + // caller: 'dispatcher-main / waiting', + // dbStatus: watchDbStatus(), + // dbReady: watchDbStatus()?.opened, + // }); return watchDbStatus()?.opened; }; @@ -49,7 +49,7 @@ const dispatch = async ( callBack?: (error: any, result: any, id?: number | undefined) => void, live?: boolean ) => { - console.log({ caller: 'dispatcher-main / dispatch', payload, callBack }); + // console.log({ caller: 'dispatcher-main / dispatch', payload, callBack }); if (worker === undefined) { init(); } @@ -73,11 +73,11 @@ const dispatch = async ( payload: payload, }; worker.postMessage(message); - console.log({ - caller: 'dispatcher-main / message sent', - message, - dispatcherQueue, - }); + // console.log({ + // caller: 'dispatcher-main / message sent', + // message, + // dispatcherQueue, + // }); }; export const cancelDispatch = (id: number) => { diff --git a/src/workers/dispatcher-worker.ts b/src/workers/dispatcher-worker.ts index 7109e19..58d81bc 100644 --- a/src/workers/dispatcher-worker.ts +++ b/src/workers/dispatcher-worker.ts @@ -67,35 +67,35 @@ onmessage = async function (e) { putAccount, }; - console.log({ caller: 'dispatcher-worker / onmessage', e }); + // console.log({ caller: 'dispatcher-worker / onmessage', e }); initDb(); await until(() => globalThis.dbReady, 100); // Wait until databases have been initialized in this worker const { id, payload } = e.data; var returnValue: any = 'unknownAction'; if (payload.action in actions) { - console.log({ - caller: 'dispatcher-worker / awaiting', - id, - payload, - dbReady: globalThis.dbReady, - }); + // console.log({ + // caller: 'dispatcher-worker / awaiting', + // id, + // payload, + // dbReady: globalThis.dbReady, + // }); returnValue = await actions[payload.action]({ ...payload.params, _dispatchId: id, }); } postMessage({ id: id, payload: returnValue }); - console.log({ - caller: 'dispatcher-worker / response sent', - id, - returnValue, - dbReady: globalThis.dbReady, - }); + // console.log({ + // caller: 'dispatcher-worker / response sent', + // id, + // returnValue, + // dbReady: globalThis.dbReady, + // }); }; export const returnAgain = (id: number, returnValue: any) => { - console.log({ caller: 'dispatcher-worker / returnAgain', id, returnValue }); + // console.log({ caller: 'dispatcher-worker / returnAgain', id, returnValue }); postMessage({ id: id, payload: returnValue }); };