shssoichiro / diesel-logger Goto Github PK
View Code? Open in Web Editor NEWTimes and logs queries executed by diesel
License: MIT License
Times and logs queries executed by diesel
License: MIT License
Running something like this doesn't seem to work: RUST_LOG="debug" ./targets/debug/foo
I can't get it to log any queries (since none of them take more than 5 seconds yet)
Any readme documentation would be helpful.
Hi!
I am using diesel_async.
How do you think about creating a logger compatible with an async connection?
Thanks!
Is there an example or any documentation on how to use this with Diesel 2.x rc1?
I'm using a connection pool right now -- something like this:
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<PgConnection>::new(database_url);
let connection_pool = Pool::builder()
.max_size(15)
.build(manager)
.expect("Unable to build connection pool.");
pub fn connect(&self) -> Result<PooledConnection<ConnectionManager<PgConnection>>> {
Ok(self.connection_pool.clone().get()?)
}
Using my connect function to get PooledConnection<ConnectionManager<PgConnection>>
then using that with LoggingConnection
produces a compile error.
// Produces an error
let conn = LoggingConnection::new(conn);
error[E0407]: method `load` is not a member of trait `Connection`
--> /Users/onx2/.cargo/git/checkouts/diesel-logger-4ba13af74e9b7c3c/915602c/src/lib.rs:98:5
|
98 | / fn load<'conn, 'query, T>(
99 | | &'conn mut self,
100 | | source: T,
101 | | ) -> QueryResult<LoadRowIter<'conn, 'query, Self, Self::Backend>>
... |
114 | | res
115 | | }
| |_____^ not a member of trait `Connection`
error[E0599]: the method `load` exists for type parameter `C`, but its trait bounds were not satisfied
--> /Users/onx2/.cargo/git/checkouts/diesel-logger-4ba13af74e9b7c3c/915602c/src/lib.rs:112:35
|
112 | let res = self.connection.load(query);
| ^^^^ method cannot be called on `C` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`C: Table`
which is required by `C: diesel::RunQueryDsl<_>`
`&C: Table`
which is required by `&C: diesel::RunQueryDsl<_>`
`&mut C: Table`
which is required by `&mut C: diesel::RunQueryDsl<_>`
Some errors have detailed explanations: E0407, E0599.
For more information about an error, try `rustc --explain E0407`.
error: could not compile `diesel_logger` due to 2 previous errors
[Finished running. Exit status: 101]
I'm using the master branch right now because I don't think the most recent version on crates has the most recent code:
diesel = { git = "https://github.com/diesel-rs/diesel", branch = "2.0.x", features = ["chrono", "postgres", "r2d2", "uuid", "serde_json"] }
diesel_logger = { git = "https://github.com/shssoichiro/diesel-logger", branch = "master" }
Queries via SimpleConnection::batch_execute
are currently not logged.
These can be useful to see in some cases, in particular batch_execute
is used by diesel's Migrations. It's also used by the TransactionManager
which would make the logging chattier if this were supported, particularly when there's lots of transactions in flight, e.g.:
[2020-09-15T20:13:03Z DEBUG diesel_logger] Query ran in 0.4 ms: RELEASE SAVEPOINT diesel_savepoint_1
[2020-09-15T20:13:03Z DEBUG diesel_logger] Query ran in 0.4 ms: SAVEPOINT diesel_savepoint_1
It could always be an option.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.