Skip to content

logging should not use global state/variables #429

Closed
@BlackHC

Description

@BlackHC

hierarchicalLoggingEnabled, recordStackTraceAtLevel, _rootLevel (and also the _loggers static field) are all global which makes testing code that uses global loggers difficult.

A solution could be to use expandos that are keyed to a zone environment variable for the 'global' logging state. This would make it easy to decouple tests.

Activity

natebosch

natebosch commented on Mar 12, 2020

@natebosch
Member

I worry that making these variables, which are already confusing and hard to reason about, zone level concepts we are just making things harder for ourselves.

See #441

If anything I think we should consider an entire overhaul of the API which doesn't suffer from these global impacts. Within that design we should certainly consider whether having some sort of zone scoped log variable would be useful - that's what we do in package:build and it has been working well for us. https://pub.dev/documentation/build/latest/build/log.html

Closing for now since I don't think we plan on addressing this with the current design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @BlackHC@natebosch@mosuem

        Issue actions

          logging should not use global state/variables · Issue #429 · dart-lang/core