Open wakille opened 10 months ago
There is no supported way to do this. logger::start_query
is getting called way too early to even have a chance knowing about any parameters. This is done so logging is effective whether the query succeeds or not.
I can't speak of any plans of including such a feature, though.
For me you exactly explained the main issue with the current logging, I cant see afterwards if the query succeded or not. And I cant track afterwards what has been written to the database. How big do guess the effort to enable soci to support the logging described previously by me ?
Generally speaking, you can assume that a query has succeeded when no exception is thrown.
In terms of effort for adding this feature, I'd say it's probably just a matter of adding something like logger::execute_query(std::string query_with_values)
in the execution step of soci::statement
. I can definitely see the benefit in terms of tracing queries here.
Feel free to create a PR for that!
Is there any plan for a 4.x version release ?
I think that the next release is mostly blocked by #954, but I can't tell you when we're able to land these changes.
FWIW I agree that having a way to log the values of the parameters (if I understand correctly what you'd like to do here?) would be useful. And I'll try to merge #954 and make a release a.s.a.p.
Yeah, that would be really nice. I looked into the sqlite3 documentation and there is a method to get the expanded query as string. The main issue I saw in implementing this in your project is, that you are not logging in the backends. So either the way how you execute the the prepared query’s or the way you log has to change for this. I can also help implement this if you can give man like some plan how you want it implemented. Could we take this logging into the upcoming release ?
As statement_impl
already has a session_
member, it could pass session_.get_logger()
to some new backend log_statement_execution()
function. Am I missing some difficulty here?
Hello, for my use case it is important to log the exact query executed, which is by default not possible with prepared statements, as I unterstand. (You can only see the prepared statement before the preparation). Is there any good practice on achiving this with prepared statements or do you plan to include this feature in upcoming releases ?
Thanks