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

add set_log_hook/1 #266

Merged
merged 3 commits into from
Oct 19, 2023
Merged

add set_log_hook/1 #266

merged 3 commits into from
Oct 19, 2023

Conversation

ruslandoga
Copy link
Contributor

@ruslandoga ruslandoga commented Oct 19, 2023

Continues from #235

Based on #260

@ruslandoga ruslandoga mentioned this pull request Oct 19, 2023
@ruslandoga ruslandoga force-pushed the error-logger branch 3 times, most recently from 3742b8f to 1df4a0d Compare October 19, 2023 08:03
@ruslandoga ruslandoga marked this pull request as ready for review October 19, 2023 08:03
@ruslandoga ruslandoga changed the title add set_error_log/2 add set_log_hook/2 Oct 19, 2023
@ruslandoga ruslandoga marked this pull request as draft October 19, 2023 09:05
@ruslandoga ruslandoga changed the title add set_log_hook/2 add set_log_hook/1 Oct 19, 2023
@ruslandoga ruslandoga marked this pull request as ready for review October 19, 2023 09:41
}

log_hook_pid = pid;
sqlite3_config(SQLITE_CONFIG_LOG, log_callback, NULL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a shame this log hook is global like this. I wish it were on a per sqlite database basis, but alas it is not. But I supposed you would only utilize this in a dev or test environment to track down a bug.

Copy link
Contributor Author

@ruslandoga ruslandoga Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason it's not per database is -- I guess -- to also be able to cover errors coming from opening invalid databases and some other operations that happen prior to getting a reference to a database.

The docs actually suggest using it in production: https://www.sqlite.org/errlog.html

Developers are encouraged to implement an error logger callback early in the development cycle in order to spot unexpected behavior quickly, and to leave the error logger callback turned on through deployment.

Copy link
Member

@warmwaffles warmwaffles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@warmwaffles warmwaffles merged commit 7ed9631 into elixir-sqlite:main Oct 19, 2023
@ruslandoga ruslandoga deleted the error-logger branch October 19, 2023 15:03
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.

2 participants