Skip to content

Conversation

@fulleni
Copy link
Member

@fulleni fulleni commented Oct 7, 2025

Status

READY

Description

This pull request significantly enhances the application's logging infrastructure by moving from ad-hoc print statements to a robust, centralized logging package. It establishes a clear logging configuration in the bootstrap process, integrates logging directly into the GoRouter's redirect mechanisms, and introduces a dedicated observer to meticulously track and report navigation events, thereby improving maintainability and debugging capabilities.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

- Set root logger level to ALL
- Add log record listener to print log messages with level, time, logger name, and message
- Refactor Logger root listener to use arrow function syntax
- Improve code readability and maintainability
@gemini-code-assist
Copy link

Summary of Changes

Hello @fulleni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors and enhances the application's logging capabilities, with a particular focus on GoRouter navigation. It establishes a centralized logging setup, integrates the robust logging package into the router's redirect mechanisms, and introduces a dedicated observer to capture and log navigation events. This change moves away from ad-hoc print statements towards a more maintainable and configurable logging solution.

Highlights

  • Centralized Logging Configuration: The application's root logger is now configured in bootstrap.dart to capture all log levels and direct them to the console, providing a unified approach to log output.
  • GoRouter Logging Integration: The GoRouter's navigation events and redirect logic have been updated to utilize the logging package, replacing direct print statements with more structured and configurable log messages (info and warning levels).
  • New GoRouter Observer: A new GoRouterObserver class has been introduced to specifically log GoRouter navigation events such as didPush, didPop, didRemove, and didReplace, offering better visibility into routing activity.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a good step towards improving logging by replacing print statements with the logging package and introducing a GoRouterObserver. My review focuses on making the new logging setup more robust and production-ready. I've included suggestions to make the logger configuration environment-aware, to ensure the new GoRouterObserver is actually utilized, and to improve the clarity of navigation logs.

@fulleni
Copy link
Member Author

fulleni commented Oct 7, 2025

/gemini summary

@fulleni
Copy link
Member Author

fulleni commented Oct 7, 2025

/gemini review

@gemini-code-assist
Copy link

Summary of Changes

This pull request significantly enhances the application's logging infrastructure by moving from ad-hoc print statements to a robust, centralized logging package. It establishes a clear logging configuration in the bootstrap process, integrates logging directly into the GoRouter's redirect mechanisms, and introduces a dedicated observer to meticulously track and report navigation events, thereby improving maintainability and debugging capabilities.

Highlights

  • Centralized Logging Setup: The bootstrap.dart file now configures the root logger, setting its level based on the environment (INFO for production, ALL otherwise) and ensuring that error and stackTrace from LogRecord are printed.
  • GoRouter Logging Integration: Direct print statements within the GoRouter's redirect logic have been replaced with structured logger.info calls, improving traceability and configurability of navigation-related logs.
  • GoRouter Navigation Observer: A new GoRouterObserver class has been introduced to capture and log GoRouter navigation events (push, pop, remove, replace), providing detailed insights into the application's routing activity.
Changelog
  • lib/app/view/app.dart
    • Imported the logging package.
    • Instantiated a Logger specifically for GoRouter navigation events.
    • Passed the GoRouter specific logger to the createRouter function.
  • lib/bootstrap.dart
    • Configured the root Logger level to be Level.INFO for production and Level.ALL for other environments.
    • Set up a listener for Logger.root.onRecord to print log messages, including error and stackTrace if present.
    • Added numerous logger.config, logger.info, and logger.fine calls to log the initialization steps of various services and repositories.
    • Removed previous logger.info and logger.severe calls that used a [bootstrap] prefix.
  • lib/router/go_router_observer.dart
    • Added a new file defining GoRouterObserver, which extends NavigatorObserver.
    • Implemented didPush, didPop, didRemove, and didReplace methods to log GoRouter navigation events using a provided Logger instance.
  • lib/router/router.dart
    • Imported GoRouterObserver and the logging package.
    • Modified the createRouter function to accept a Logger instance.
    • Integrated GoRouterObserver into the GoRouter's observers list, passing the logger.
    • Replaced all print statements within the redirect logic with logger.info calls.
    • Replaced a print statement in the SettingsBloc creation with a logger.warning call.
Activity
  • gemini-code-assist[bot] provided an initial summary of the pull request.
  • gemini-code-assist[bot] suggested improvements to the root logger configuration in bootstrap.dart, recommending environment-based level setting and logging error and stackTrace from LogRecord.
  • gemini-code-assist[bot] recommended handling potential null values for route.settings.name in the GoRouterObserver methods to prevent "null" from being printed in logs.
  • fulleni requested a summary from gemini-code-assist[bot].

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great improvement, refactoring the application to use the logging package instead of ad-hoc print statements. The introduction of a centralized logging setup in bootstrap.dart and a dedicated GoRouterObserver for navigation events significantly enhances maintainability and provides more structured, configurable logging. My feedback focuses on improving the log record listener to prevent interleaved log messages, which will make debugging easier.

- Consolidate log message construction using a StringBuffer
- Format error and stack trace information consistently
- Enhance readability of log output by structuring the message
- Chaining logger methods for better readability
- Removing unnecessary print statement
- Consistent use of string interpolation
- Removing extra empty lines
- Remove relative import path for go_router_observer.dart
- Add absolute import path for go_router_observer.dart
- Ensure GoRouterObserver is correctly imported and used in the Router
@fulleni fulleni merged commit 81485d3 into main Oct 7, 2025
0 of 2 checks passed
@fulleni fulleni deleted the refactor/improve-logging branch October 7, 2025 06:30
@fulleni fulleni added this to the Foundation Edition milestone Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants