-
Notifications
You must be signed in to change notification settings - Fork 11
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
Logging support via tracing
#8
Comments
I tried getting something to work in #9 The main code is here The thing is, whenever I change the trace level from info to debug, then nothing shows up in the console. Do you have any ideas as to why? I don't think I can keep this as info because it's extremely noisy. Unless I hide it behind a feature. |
didn't mean to close it haha. also as a side note, if you just want to observer query changes, you can do the following. The tracing is the actual execution of the fetcher, and you can just use an effect to observe the query state for debugging let QueryResult { state, .. } = use_post_query(cx, post_id);
// Log the state of the query.
create_effect(cx, move |_| log!("State: {:#?}", state.get())); Full example is here |
FWIW, I use (change INFO to DEBUG) |
I wrote a wrapper around
use_query
, calleduse_server_query
, specifically geared to call server functions. The main reason (aside from the nicety of being able to pass server fn directly, and it using default options) is so that I can log the call to each server fns in a general fashion.You can find the implementation here: https://github.com/juspay/nix-browser/blob/132ed807fa909b0eaa73871b28f0f6c255b50703/src/leptos_extra/query.rs#L20-L61
The downside is that I had to make all server fns 1-ary, taking a tuple, because Rust type system is not powerful enough to let me a way find the function name at runtime for n-ary functions (the function name is used in log message).
This is used like this:
https://github.com/juspay/nix-browser/blob/132ed807fa909b0eaa73871b28f0f6c255b50703/src/app.rs#L122-L123
get_flake
is a server_fn here (taking the value ofquery
as argument), and every time either use_query is called or the fetcher is actually invoked, it logs to browser console. So, I guess, my feature request - can a similar kind of logging (via tracing instrumentation) support be added to this library?The text was updated successfully, but these errors were encountered: