Skip to content

[go_router] Initial Routes are being logged even if debugLogDiagnostics == false #134187

@feinstein

Description

@feinstein

Is there an existing issue for this?

Steps to reproduce

1 - Create a project with some routes using go_router.
2 - Add the logging package.
3 - Call this code to output all logs:

void setupLogging() {
  Logger.root.onRecord.listen((record) {
    final String message;
    final messageHeader = '${record.level.name}: ${record.time}: ${record.message}';
    if (record.level < Level.SEVERE) {
      message = messageHeader;
    } else {
      message = '$messageHeader : ${record.error} : ${record.stackTrace}';
    }

    if (kDebugMode) {
      print(message);
    }
  });
}

4 - You will see GoRouter prints all the known routes when the app starts up.

This is happening because RouteConfiguration calls log.info(debugKnownRoutes()) on it's constructor

Expected results

No logs should be created if debugLogDiagnostics is false. This excessive logs will add irrelevant information to monitoring tools.

Actual results

Logs are being printed when debugLogDiagnostics is false.

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions