Skip to content

Logging support via tracing #8

@srid

Description

@srid

I wrote a wrapper around use_query, called use_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

    let (query, set_query) = use_signal::<FlakeUrl>(cx);
    let result = query::use_server_query(cx, query, get_flake);

get_flake is a server_fn here (taking the value of query 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions