-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Create a project with some routes using
go_routerversion >=11.1.2. - set
hierarchicalLoggingEnabledtotruein themainfunction of the project - listen to
onRecordstream ofLogger('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);
}
}