• 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
resident_web_runner_cold_test.dart 8.37 KB