Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting SQLite3 error-logging callback #419

Open
sburton84 opened this issue Apr 24, 2023 · 2 comments
Open

Setting SQLite3 error-logging callback #419

sburton84 opened this issue Apr 24, 2023 · 2 comments

Comments

@sburton84
Copy link

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?

@SRombauts
Copy link
Owner

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

@sburton84
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants