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

Error logging #111

Merged
merged 7 commits into from
May 13, 2017
Merged

Error logging #111

merged 7 commits into from
May 13, 2017

Conversation

zauguin
Copy link
Collaborator

@zauguin zauguin commented Apr 25, 2017

Implement SQL error logging based on error classes.

Closes #109.

@zauguin zauguin changed the title [WIP] Error logging Error logging Apr 26, 2017
@zauguin
Copy link
Collaborator Author

zauguin commented Apr 26, 2017

@bstarynk Maybe you can help testing this?

@aminroosta
Copy link
Collaborator

@bstarynk Could you please comment :-)

@bstarynk
Copy link

bstarynk commented Apr 28, 2017

I am not sure to understand how this should be used in practice (I am probably confused by the relation between Sqlite errors and C++ exceptions). Maybe more comments could be useful. I am not sure to only want the error logging function to be activated after throwing some exception (but perhaps before that).

BTW, in my melt-monitor (on github, e.g. commit 5b29edf1ef1b6621a0......) I have an additional wish. I am using extensively Ian Taylor's libbacktrace, and I would like to print the backtrace before throwing any sqlite exception.

@bstarynk
Copy link

BTW, I would also like such new features to be testable with preprocessor flags, that is have perhaps #define SQLITE_MODERNCPP_HAS_ERRORLOG 1 so that my application could code #if SQLITE_MODERNCPP_HAS_ERRORLOG ....

@zauguin
Copy link
Collaborator Author

zauguin commented Apr 28, 2017

@bstarynk This may be a documentation issue, why do you think the error logging is called after throwing the exception?

The error logging, based on the SQLite log functionality, is kind of independant of C++ exceptions. During execution, if SQLite detects an error, it calls the error log callback. Your handler is called with a sqlite_exception derived parameter to encode the error code, but this isn't a thrown exception. The exception is independently thrown at a later point.

So using libbacktrace should work, just replace the cerr << ... by your libbacktrace based error handling functionality.

@zauguin
Copy link
Collaborator Author

zauguin commented Apr 28, 2017

This feature is implemented in a separate header, so with most modern compiler (gcc >= 5, clang, VC++ 2015(?)) you can test for it with __has_include. For example

#if __has_include(<sqlite_modern_cpp/log.h>)
...
#endif

@zauguin zauguin merged commit 56af65d into SqliteModernCpp:master May 13, 2017
@zauguin zauguin deleted the logging2 branch May 13, 2017 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants