Skip to content

[go_router] Execute log method when hierarchicalLoggingEnabled is true regardless of debugLogDiagnostics value #139667

@ycherniavskyi

Description

@ycherniavskyi

Is there an existing issue for this?

Steps to reproduce

  1. Create a project with some routes using go_router version >=11.1.2.
  2. set hierarchicalLoggingEnabled to true in the main function of the project
  3. listen to onRecord stream of Logger('GoRouter')

Before flutter/packages#4875 everything works as described in expected resiles.

Expected results

Get event from onRecord stream of Logger('GoRouter') if hierarchicalLoggingEnabled is true regardless of debugLogDiagnostics value.

Because, if I understand it right, then if hierarchicalLoggingEnabled is true it means that you must have to control the whole logging logic from one place - the logging package, without interaction with each package that outputs logs separately.

Actual results

If debugLogDiagnostics is false then no events from onRecord stream of Logger('GoRouter') are received at all.
But if debugLogDiagnostics is true then events from onRecord stream of Logger('GoRouter') are received but they doubled in the console with default developer.log executed by go_router.

Get event from onRecord stream of Logger('GoRouter') regardless of debugLogDiagnostics value.

Proposed fix

To achieve the expected results the following condition must be extended.

From

/// Logs the message if logging is enabled.
void log(String message, {Level level = Level.INFO}) {
  if (_enabled) {
    logger.log(level, message);
  }
}

To:

/// Logs the message if logging is enabled.
void log(String message, {Level level = Level.INFO}) {
  if (_enabled || hierarchicalLoggingEnabled) {
    logger.log(level, message);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18has 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