SQLiteCpp icon indicating copy to clipboard operation
SQLiteCpp copied to clipboard

Setting SQLite3 error-logging callback

Open sburton84 opened this issue 2 years ago • 2 comments

The SQLite3 library provides a way of setting an error-logging callback, as described at https://www.sqlite.org/errlog.html but SQLiteCpp doesn't seem to provide a way of setting this callback. As far as I can tell, SQLiteCpp doesn't set this callback internally either.

What is the recommended way, when using SQLiteCpp, of logging the errors that would be sent to this callback? Is setting this callback unnecessary when using SQLiteCpp because any such errors are guaranteed to be thrown as exceptions? Or should I be using the SQLite3 interface directly, calling sqlite3_config as described in the above link, to set this callback?

sburton84 avatar Apr 24 '23 12:04 sburton84

Hey @sburton84, this is a great question! Did you decide on how you would use it in the end?

Using this SQLITE_CONFIG_LOG is a great way to help debug any applications. In fact, it would be awesome to provide explicit support and some examples of how to use it with SQLiteCpp!

Any help on setting up a basic example is appreciated

SRombauts avatar May 15 '23 12:05 SRombauts

So far I'm just including sqlite3.h directly and using sqlite3_config(SQLITE_CONFIG_LOG, ...) to set a function-pointer as the callback, I assume this should work but I'm not sure how to force an error to really test it, it doesn't get called at all during normal operation.

It would be good if SQLiteCPP included idiomatic C++ support for this, allowing a std::function<...> of some sort to be used as the callback.

sburton84 avatar May 23 '23 12:05 sburton84