console messages callback
Closed this issue · 16 comments
bonjour mon ami Jan.
yesterday, I encountered a problem that might deserve your attention.
spl initialization of the following gpkg failed due to a few views that stood in the way.
i didn't know the reason untill I tried init in the spatialite console under linux, where the error messages got shown.
therefore I'm kindly asking you to allow calling an user provided callback for standard and error console messages.
this functionality is present in the wasm port from the original SQLite site.
the above-mentioned gpkg:
https://github.com/ngageoint/geopackage-js/raw/master/docs/examples/GeoPackageToGo/StLouis.gpkg
Salut @alexbodn,
do you have a minimal example, a code snippet for me to reproduce the behavior? Did you try it in node or browser and what is the error msg from spatialite you got in the console?
salut cher @jvail
the error is legitimate initialization failure, due to some existing views in the gpkg.
open the link in my issue report in linux spatialite, and select initspatialmetadatafull(1).
you will see the error message in the console, and that's what i'd like to see in spl.js too.
at https://sqlite.org/wasm/file/demo-123.js?txt you can see the user can supply js functions to be called by wasm code to display messages:
self.sqlite3InitModule({
// We can redirect any stdout/stderr from the module
print: console.log,
printErr: console.error
})
so i could learn the problem in the browser, without turning to linux spatialite.
that will boost usage of spl.js as a development tool.
please allow this to in spl.js too.
Pardon, maybe I do not understand exactly what you are asking for .. at least this
so i could learn the problem in the browser, without turning to linux spatialite.
... is available. In node and in the browser I get the error message and the correct result which is 0.
I have just added this line to the topology example code and I get an error because the the same function was already called:
console.log(await db.exec('select initspatialmetadata(1)').get.first)
But this browser does support console.error? I am afraid, I do not have a clue. At least it is not an issue in the code.
Yes, "select a" gives an SQLite error and that is why you see the exception. But the other function just returns 0 - no exception if it fails.
yes, this is what happens on my side.
but in spatialite console a message is showed, like in your browser at:
i was missing exactly the red console.error message in your browser.
it's probably created with select raise.
Sorry, I think you need to figure out why your browser does not print the console.error output. Instead of doing a/123
in the console try a console.error("Hello Error")
in the console.
hello dear @jvail
i'm very sorry to bother with this. for me gis is still uncharted land, thus i rely on all sensors and warnings.
however i have errors and warnings,
i begin to understand i might have a limitation.
my console is eruda based, as it won't allow awaiting.
but it nevertheless allowed me to console log the result of the init in the .then of the promise, with no clue of the message.
anyway, as i told you, i have used select raise with the original sqlite wasm from sqlite.org, and did find the message in the eruda console.
will make a small snippet to show you.
Sorry, still no clue how this could be fixed or if there is at all anything to fix in spl.js. Last idea: The message is coming from within the Worker not the main thread. Maye that makes a difference in your browser/application.
i'm indebted cher ami.
this should be the culprit.
i'll check how to poll for the worker messages.
some boilerplate code in the main.
Seems it is "solved" ...
I am afraid that currently there is no option to hook into the console.log/error messages of emscripten and pass those from the worker to the main thread. But if you feel brave to make a PR to pass a function to hook into the console messages I'll definitely consider it. Bonne chance und viel Glück!