Skip to content
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

feat: jaspr_router logging #191

Open
dinko7 opened this issue Mar 25, 2024 · 1 comment
Open

feat: jaspr_router logging #191

dinko7 opened this issue Mar 25, 2024 · 1 comment
Labels

Comments

@dinko7
Copy link

dinko7 commented Mar 25, 2024

Description

GoRouter has a debugLogDiagnostics property which can be set at the router level to show logs during navigation.

Adding this to jaspr_router would help developers debug issues during routing.

The output would be identical to GoRouter's:

Output on startup:

Router: known full paths for routes:
Router:   => /
Router:   =>   /family/:fid
Router:   =>     /family/:fid/person/:pid
Router: known full paths for route names:
Router:   home => /
Router:   family => /family/:fid
Router:   person => /family/:fid/person/:pid

Output on route change:

Router: location changed to /
Router: getting location for name: "person", params: {fid: f2, pid: p1}
Router: going to /family/f2/person/p1
Router: location changed to /family/f2/person/p1

Output on error:

Router: Exception: no routes for location: /foobarquux

Contribution

I would be open to implement this. Haven't really taken a deeper look at the code, but this is what I have so far:

Add debugLogDiagnostics property to the Router:

Router({
    required this.routes,
    this.errorBuilder,
    this.redirect,
    this.redirectLimit = 5,
    this.debugLogDiagnostics = false,
  }) 
  
 final bool debugLogDiagnostics;

Output on startup would be added in the following method:

Future<RouteMatchList> _preload(RouteMatchList match) 

Output on route change would be added in the following method:

 Future<void> _update(
    String location, {
    Object? extra,
    bool updateHistory = true,
    bool replace = false,
  })

Correct me if something is wrong.

@dinko7 dinko7 added the feature label Mar 25, 2024
@schultek
Copy link
Owner

Sounds good. I think part of that is already in the implementation (see RouteConfiguration.debugKnownRoutes) but its just not used right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants