• James D. Lin's avatar
    [flutter tools] Add a DelegatingLogger class (#67581) · e4206ac5
    James D. Lin authored
    [flutter tools] Add a DelegatingLogger class
    
    Move most of `DelegateLogger` `from test/src/testbed.dart` to
    `lib/src/base/logger.dart` to better formalize the common practice of
    chaining `Logger`s together.  I renamed the class since it isn't
    itself the delegate and to better match the `Delegating...` classes
    from `package:collection`.
    
    Additionally, add a freestanding `asLogger<T>` function to "cast" a
    `Logger` into a matching delegate if possible.  This will allow
    `Logger` chains to be ordered a *bit* more freely (e.g.
    `NotifyingLogger` and `AppRunLogger` will no longer required to be
    at the end of the chain, an unwritten rule that has led to breakage in
    google3).  Chain order still matters since lack of virtual dispatch
    means that parent `Logger`s can never invoke child methods, however.
    
    I made `asLogger<T>` a freestanding function because I didn't want to
    make it part of the `Logger` interface (and I thought that making it
    an extension method might be weird).
    
    Bonus cleanup:
    There no longer appears to be a way to construct an `AppRunLogger`
    with a null parent, so remove all of code paths for that case and
    make the `parent` construction parameter required.
    e4206ac5
Name
Last commit
Last update
.github Loading commit data...
bin Loading commit data...
dev Loading commit data...
examples Loading commit data...
packages Loading commit data...
.cirrus.yml Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CODEOWNERS Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
PATENT_GRANT Loading commit data...
README.md Loading commit data...
analysis_options.yaml Loading commit data...
dartdoc_options.yaml Loading commit data...
flutter_console.bat Loading commit data...