1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Add capability to override the JS's use of console.log/debug/warn/error() with client-provided versions via the bootstrap-time config object.

FossilOrigin-Name: c54f29d8e55419eaa9168e799dab5030e89063b13d8390a50616606422d164dc
This commit is contained in:
stephan
2023-02-06 14:01:19 +00:00
parent ee18659f69
commit 3ff812aa94
9 changed files with 59 additions and 41 deletions

View File

@ -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;
}
}