thedodd / wither

An ODM for MongoDB built on the official MongoDB Rust driver.
https://docs.rs/wither
Other
324 stars 40 forks source link

Logging Output #58

Open No9 opened 4 years ago

No9 commented 4 years ago

Hi There First of all thanks very much for putting this driver together - I'm really enjoying working with it.

I noticed from the docs that logging is available but if I understand the code correctly it's only used in migrations: https://github.com/thedodd/wither/search?q=log&type=Code

Is my understanding correct?

FYI I have also put together a small sample app using this lib with tide and handlebars https://github.com/No9/tide-morth-example/

Thanks again for your work.

thedodd commented 4 years ago

@No9 as of master today, yes. That is correct. Previously, there was a bit more logging within the index synchronization code; however, that has been removed recently due to some driver limitations discussed over in #51.

Right now, almost everything is a thin layer over top of the driver, which allows for the model based approach. There isn't much to log. However, along those lines, if you do think that perhaps more logging is merited, I am certainly open to that. I've even considered adding in support for the tracing library, but I'm not sure on that one.

Thoughts?

No9 commented 4 years ago

I think tracing may be the way to go - Just wanted to confirm that I wasn't missing anything on the logging. I'd like to get e2e tracing into the sample app - I'll take a look and ping back when I know more. Feel free to close this in the meantime.

thedodd commented 3 years ago

@No9 if you are up to the challenge, I think an excellent approach for this lib would be to use #[tracing::instrument(level="trace")] on our Model trait. Any other async methods / functions called in the lib can be similarly decorated.

If you are down to do so, we could probably factor the code into the upcoming 0.9.0 release. Just let me know :)