diff --git a/packages/puter-js/src/index.js b/packages/puter-js/src/index.js index 549d163a..64784cf2 100644 --- a/packages/puter-js/src/index.js +++ b/packages/puter-js/src/index.js @@ -48,6 +48,9 @@ window.puter = (function() { // Event handling properties eventHandlers = {}; + // debug flag + debugMode = false; + // -------------------------------------------- // Constructor // -------------------------------------------- @@ -307,7 +310,6 @@ window.puter = (function() { } } - // Create a new Puter object and return it const puterobj = new Puter(); diff --git a/packages/puter-js/src/modules/AI.js b/packages/puter-js/src/modules/AI.js index 34632510..edf9abb4 100644 --- a/packages/puter-js/src/modules/AI.js +++ b/packages/puter-js/src/modules/AI.js @@ -69,7 +69,6 @@ class AI{ testMode = true; } - console.log(args, options); return await utils.make_driver_method(['source'], 'puter-ocr', 'recognize', { test_mode: testMode ?? false, transform: async (result) => { diff --git a/packages/puter-js/src/modules/FileSystem/index.js b/packages/puter-js/src/modules/FileSystem/index.js index e39805cc..a5540102 100644 --- a/packages/puter-js/src/modules/FileSystem/index.js +++ b/packages/puter-js/src/modules/FileSystem/index.js @@ -75,31 +75,38 @@ class FileSystem{ bindSocketEvents() { this.socket.on('connect', () => { - console.log('FileSystem Socket: Connected', this.socket.id); + if(puter.debugMode) + console.log('FileSystem Socket: Connected', this.socket.id); }); this.socket.on('disconnect', () => { - console.log('FileSystem Socket: Disconnected'); + if(puter.debugMode) + console.log('FileSystem Socket: Disconnected'); }); this.socket.on('reconnect', (attempt) => { - console.log('FileSystem Socket: Reconnected', this.socket.id); + if(puter.debugMode) + console.log('FileSystem Socket: Reconnected', this.socket.id); }); this.socket.on('reconnect_attempt', (attempt) => { - console.log('FileSystem Socket: Reconnection Attemps', attempt); + if(puter.debugMode) + console.log('FileSystem Socket: Reconnection Attemps', attempt); }); this.socket.on('reconnect_error', (error) => { - console.log('FileSystem Socket: Reconnection Error', error); + if(puter.debugMode) + console.log('FileSystem Socket: Reconnection Error', error); }); this.socket.on('reconnect_failed', () => { - console.log('FileSystem Socket: Reconnection Failed'); + if(puter.debugMode) + console.log('FileSystem Socket: Reconnection Failed'); }); this.socket.on('error', (error) => { - console.error('FileSystem Socket Error:', error); + if(puter.debugMode) + console.error('FileSystem Socket Error:', error); }); } diff --git a/packages/puter-js/src/modules/FileSystem/operations/upload.js b/packages/puter-js/src/modules/FileSystem/operations/upload.js index 8aab5d6c..4b7fe525 100644 --- a/packages/puter-js/src/modules/FileSystem/operations/upload.js +++ b/packages/puter-js/src/modules/FileSystem/operations/upload.js @@ -386,7 +386,8 @@ const upload = async function(items, dirPath, options = {}){ else{ if(!resp || !resp.results || resp.results.length === 0){ // no results - console.log('no results'); + if(puter.debugMode) + console.log('no results'); } let items = resp.results; diff --git a/packages/puter-js/test/fs.test.js b/packages/puter-js/test/fs.test.js index 1f2e4bc1..ba5887dc 100644 --- a/packages/puter-js/test/fs.test.js +++ b/packages/puter-js/test/fs.test.js @@ -120,7 +120,8 @@ window.fsTests = [ throw("testFSWrite failed to delete file:", error); } } catch (error) { - console.log(error); + if(puter.debugMode) + console.log(error); throw("testFSWrite failed:", error); } }, @@ -598,7 +599,6 @@ window.fsTests = [ let randName = puter.randName(); for(let i = 0; i < naughtyStrings.length; i++) { let filename = randName + naughtyStrings[i]; - console.log(filename); let result = await puter.fs.write(filename, 'testValue'); assert(result.uid, "Failed to write to file"); // check name