Skip to content

logging should not use global state/variables #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BlackHC opened this issue Sep 2, 2015 · 1 comment
Closed

logging should not use global state/variables #429

BlackHC opened this issue Sep 2, 2015 · 1 comment
Labels
package:logging type-enhancement A request for a change that isn't a bug

Comments

@BlackHC
Copy link

BlackHC commented Sep 2, 2015

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.

@natebosch
Copy link
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.

@natebosch natebosch added the type-enhancement A request for a change that isn't a bug label Mar 12, 2020
@mosuem mosuem transferred this issue from dart-archive/logging Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:logging type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants