diff options
Diffstat (limited to 'ext/wasm/api')
-rw-r--r-- | ext/wasm/api/sqlite3-api-oo1.js | 12 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-api-prologue.js | 10 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-api-worker1.js | 4 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-opfs-async-proxy.js | 12 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 20 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | 4 |
6 files changed, 36 insertions, 26 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index 26aa80f72..914497602 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -136,7 +136,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ if(('string'!==typeof fn && 'number'!==typeof fn) || 'string'!==typeof flagsStr || (vfsName && ('string'!==typeof vfsName && 'number'!==typeof vfsName))){ - console.error("Invalid DB ctor args",opt,arguments); + sqlite3.config.error("Invalid DB ctor args",opt,arguments); toss3("Invalid arguments for DB constructor."); } let fnJs = ('number'===typeof fn) ? wasm.cstrToJs(fn) : fn; @@ -881,7 +881,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ stmt = null; } }/*catch(e){ - console.warn("DB.exec() is propagating exception",opt,e); + sqlite3.config.warn("DB.exec() is propagating exception",opt,e); throw e; }*/finally{ if(stmt){ @@ -1278,7 +1278,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ function returns that value, else it throws. */ const affirmSupportedBindType = function(v){ - //console.log('affirmSupportedBindType',v); + //sqlite3.config.log('affirmSupportedBindType',v); return isSupportedBindType(v) || toss3("Unsupported bind() argument type:",typeof v); }; @@ -1394,7 +1394,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ break; } default: - console.warn("Unsupported bind() argument type:",val); + sqlite3.config.warn("Unsupported bind() argument type:",val); toss3("Unsupported bind() argument type: "+(typeof val)); } if(rc) DB.checkRc(stmt.db.pointer, rc); @@ -1599,7 +1599,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ case capi.SQLITE_ROW: return this._mayGet = true; default: this._mayGet = false; - console.warn("sqlite3_step() rc=",rc, + sqlite3.config.warn("sqlite3_step() rc=",rc, capi.sqlite3_js_rc_str(rc), "SQL =", capi.sqlite3_sql(this.pointer)); DB.checkRc(this.db.pointer, rc); @@ -1722,7 +1722,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ hope for the best, as the C API would do. */ toss3("Integer is out of range for JS integer range: "+rc); } - //console.log("get integer rc=",rc,isInt32(rc)); + //sqlite3.config.log("get integer rc=",rc,isInt32(rc)); return util.isInt32(rc) ? (rc | 0) : rc; } } diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index 137ab1ee7..b08ad7a7c 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -82,6 +82,12 @@ the `realloc(3)`-compatible routine for the WASM environment. Defaults to `"sqlite3_realloc"`. + - `debug`, `log`, `warn`, and `error` may be functions equivalent + to the like-named methods of the global `console` object. By + default, these map directly to their `console` counterparts, but + can be replaced with (e.g.) empty functions to squelch all such + output. + - `wasmfsOpfsDir`[^1]: As of 2022-12-17, this feature does not currently work due to incompatible Emscripten-side changes made in the WASMFS+OPFS combination. This option is currently ignored. @@ -113,6 +119,10 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( } return !!self.BigInt64Array; })(), + debug: console.debug.bind(console), + warn: console.warn.bind(console), + error: console.error.bind(console), + log: console.log.bind(console), wasmfsOpfsDir: '/opfs', /** useStdAlloc is just for testing an allocator discrepancy. The diff --git a/ext/wasm/api/sqlite3-api-worker1.js b/ext/wasm/api/sqlite3-api-worker1.js index 58b9b0091..f82be6cd0 100644 --- a/ext/wasm/api/sqlite3-api-worker1.js +++ b/ext/wasm/api/sqlite3-api-worker1.js @@ -612,8 +612,8 @@ sqlite3.initWorker1API = function(){ result.stack = ('string'===typeof err.stack) ? err.stack.split(/\n\s*/) : err.stack; } - if(0) console.warn("Worker is propagating an exception to main thread.", - "Reporting it _here_ for the stack trace:",err,result); + if(0) sqlite3.config.warn("Worker is propagating an exception to main thread.", + "Reporting it _here_ for the stack trace:",err,result); } if(!dbId){ dbId = result.dbId/*from 'open' cmd*/ diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index 1456ae08d..b1ad9152e 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -74,9 +74,9 @@ const installAsyncProxy = function(self){ state.verbose = 1; const loggers = { - 0:console.error.bind(console), - 1:console.warn.bind(console), - 2:console.log.bind(console) + 0:sqlite3.config.error.bind(console), + 1:sqlite3.config.warn.bind(console), + 2:sqlite3.config.log.bind(console) }; const logImpl = (level,...args)=>{ if(state.verbose>level) loggers[level]("OPFS asyncer:",...args); @@ -106,12 +106,12 @@ const installAsyncProxy = function(self){ w += m.wait; m.avgTime = (m.count && m.time) ? (m.time / m.count) : 0; } - console.log(self.location.href, + sqlite3.config.log(self.location.href, "metrics for",self.location.href,":\n", metrics, "\nTotal of",n,"op(s) for",t,"ms", "approx",w,"ms spent waiting on OPFS APIs."); - console.log("Serialization metrics:",metrics.s11n); + sqlite3.config.log("Serialization metrics:",metrics.s11n); }; /** @@ -272,7 +272,7 @@ const installAsyncProxy = function(self){ || (e.cause.name==='DOMException' && 0===e.cause.message.indexOf('Access Handles cannot'))) ) ? ( - /*console.warn("SQLITE_BUSY",e),*/ + /*sqlite3.config.warn("SQLITE_BUSY",e),*/ state.sq3Codes.SQLITE_BUSY ) : rc; }else{ diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index 451f0019c..3e3255b0c 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -112,16 +112,16 @@ const installOpfsVfs = function callee(options){ options.proxyUri = callee.defaultProxyUri; } - //console.warn("OPFS options =",options,self.location); + //sqlite3.config.warn("OPFS options =",options,self.location); if('function' === typeof options.proxyUri){ options.proxyUri = options.proxyUri(); } const thePromise = new Promise(function(promiseResolve, promiseReject_){ const loggers = { - 0:console.error.bind(console), - 1:console.warn.bind(console), - 2:console.log.bind(console) + 0:sqlite3.config.error.bind(console), + 1:sqlite3.config.warn.bind(console), + 2:sqlite3.config.log.bind(console) }; const logImpl = (level,...args)=>{ if(options.verbose>level) loggers[level]("OPFS syncer:",...args); @@ -171,11 +171,11 @@ const installOpfsVfs = function callee(options){ m.avgTime = (m.count && m.time) ? (m.time / m.count) : 0; m.avgWait = (m.count && m.wait) ? (m.wait / m.count) : 0; } - console.log(self.location.href, + sqlite3.config.log(self.location.href, "metrics for",self.location.href,":",metrics, "\nTotal of",n,"op(s) for",t, "ms (incl. "+w+" ms of waiting on the async side)"); - console.log("Serialization metrics:",metrics.s11n); + sqlite3.config.log("Serialization metrics:",metrics.s11n); W.postMessage({type:'opfs-async-metrics'}); }, reset: function(){ @@ -945,7 +945,7 @@ const installOpfsVfs = function callee(options){ await opfsUtil.getDirForFilename(absDirName+"/filepart", true); return true; }catch(e){ - //console.warn("mkdir(",absDirName,") failed:",e); + //sqlite3.config.warn("mkdir(",absDirName,") failed:",e); return false; } }; @@ -1317,13 +1317,13 @@ self.sqlite3ApiBootstrap.initializersAsync.push(async (sqlite3)=>{ if(sqlite3.scriptInfo.sqlite3Dir){ installOpfsVfs.defaultProxyUri = sqlite3.scriptInfo.sqlite3Dir + proxyJs; - //console.warn("installOpfsVfs.defaultProxyUri =",installOpfsVfs.defaultProxyUri); + //sqlite3.config.warn("installOpfsVfs.defaultProxyUri =",installOpfsVfs.defaultProxyUri); } return installOpfsVfs().catch((e)=>{ - console.warn("Ignoring inability to install OPFS sqlite3_vfs:",e.message); + sqlite3.config.warn("Ignoring inability to install OPFS sqlite3_vfs:",e.message); }); }catch(e){ - console.error("installOpfsVfs() exception:",e); + sqlite3.config.error("installOpfsVfs() exception:",e); throw e; } }); diff --git a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js index 1689d3480..0f1ae39ea 100644 --- a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js +++ b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js @@ -246,9 +246,9 @@ self.sqlite3Worker1Promiser.defaultConfig = { const src = this.currentScript.src.split('/'); src.pop(); theJs = src.join('/')+'/' + theJs; - //console.warn("promiser currentScript, theJs =",this.currentScript,theJs); + //sqlite3.config.warn("promiser currentScript, theJs =",this.currentScript,theJs); }else{ - //console.warn("promiser self.location =",self.location); + //sqlite3.config.warn("promiser self.location =",self.location); const urlParams = new URL(self.location.href).searchParams; if(urlParams.has('sqlite3.dir')){ theJs = urlParams.get('sqlite3.dir') + '/' + theJs; |