{"action":"created","issue":{"url":"https://api.github.com/repos/diesel-rs/diesel/issues/150","repository_url":"https://api.github.com/repos/diesel-rs/diesel","labels_url":"https://api.github.com/repos/diesel-rs/diesel/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/diesel-rs/diesel/issues/150/comments","events_url":"https://api.github.com/repos/diesel-rs/diesel/issues/150/events","html_url":"https://github.com/diesel-rs/diesel/issues/150","id":130053523,"node_id":"MDU6SXNzdWUxMzAwNTM1MjM=","number":150,"title":"Let's figure out logging","user":{"login":"sgrif","id":1529387,"node_id":"MDQ6VXNlcjE1MjkzODc=","avatar_url":"https://avatars2.githubusercontent.com/u/1529387?v=4","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"labels":[{"id":293106372,"node_id":"MDU6TGFiZWwyOTMxMDYzNzI=","url":"https://api.github.com/repos/diesel-rs/diesel/labels/accepted","name":"accepted","color":"009800","default":false},{"id":292827063,"node_id":"MDU6TGFiZWwyOTI4MjcwNjM=","url":"https://api.github.com/repos/diesel-rs/diesel/labels/discussion%20desired","name":"discussion desired","color":"bfd4f2","default":false},{"id":254193214,"node_id":"MDU6TGFiZWwyNTQxOTMyMTQ=","url":"https://api.github.com/repos/diesel-rs/diesel/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-01-30T23:41:12Z","updated_at":"2018-08-14T13:10:12Z","closed_at":null,"author_association":"MEMBER","body":"As I'm adding SQLite support, I'm finding it annoying to track down cases like ```called `Result::unwrap()` on an `Err` value: DatabaseError(\"SQL logic error or missing database\")```.\r\n\r\nThis should definitely be injectable, and I'd prefer that it be decoupled from the individual connection classes, but I'm not sure that's actually possible.\r\n\r\nI'd originally imagined something like `LoggingConnection` being a struct, which wrapped another `T: Connection`, and ran everything through the `DebugQueryBuilder` (and eventually cached it through the same mechanisms that we add for prepared statement caching). This should also log the values for the bind params. I am fine with adding the constraint `ToSql<ST, DB>: Debug` to accommodate this, as basically everything should implement it.\r\n\r\nHowever, given that `DebugQueryBuilder` can have output which potentially differs from the actual SQL executed (for example, we're currently figuring out how to deal with SQLite's lack of a `DEFAULT` keyword, and I don't see how what we end up doing can actually be reflected in `DebugQueryBuilder`). So perhaps the correct answer is to have a `set_logger` method added to `Connection`.\r\n\r\nUltimately I'm undecided on this, and am open to either solution, if presented as a working PR. Discussion about how to go about this, or use cases that we think we need to support is certainly welcomed.\r\n"},"comment":{"url":"https://api.github.com/repos/diesel-rs/diesel/issues/comments/412865993","html_url":"https://github.com/diesel-rs/diesel/issues/150#issuecomment-412865993","issue_url":"https://api.github.com/repos/diesel-rs/diesel/issues/150","id":412865993,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjg2NTk5Mw==","user":{"login":"weiznich","id":1674512,"node_id":"MDQ6VXNlcjE2NzQ1MTI=","avatar_url":"https://avatars1.githubusercontent.com/u/1674512?v=4","gravatar_id":"","url":"https://api.github.com/users/weiznich","html_url":"https://github.com/weiznich","followers_url":"https://api.github.com/users/weiznich/followers","following_url":"https://api.github.com/users/weiznich/following{/other_user}","gists_url":"https://api.github.com/users/weiznich/gists{/gist_id}","starred_url":"https://api.github.com/users/weiznich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weiznich/subscriptions","organizations_url":"https://api.github.com/users/weiznich/orgs","repos_url":"https://api.github.com/users/weiznich/repos","events_url":"https://api.github.com/users/weiznich/events{/privacy}","received_events_url":"https://api.github.com/users/weiznich/received_events","type":"User","site_admin":false},"created_at":"2018-08-14T13:10:12Z","updated_at":"2018-08-14T13:10:12Z","author_association":"CONTRIBUTOR","body":"@diesel-rs/core I would like to propose that we discuss this issue again in the context of diesel 2.0.\r\n\r\n> The main problem with that implementation is that I made the mistake of encouraging code written as &PgConnection, not C: Connection<Backend = Pg>, meaning this will likely need to be part of Connection itself.\r\n\r\nCouldn't this be simply \"solved\" by doing `type PgConnection = LogConnection<diesel::PgConnection, MyLogger>;` in your crate root and then fixing the includes?"}}
{"actor":{"display_login":"weiznich"}}