Skip to content
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

What is the reason to make them as top-level variable instead of as static fields to the Logger class? #104

Open
rockyoung opened this issue Sep 14, 2021 · 1 comment

Comments

@rockyoung
Copy link

bool hierarchicalLoggingEnabled = false;

Level recordStackTraceAtLevel = Level.OFF;

// Obviously below way should be more clear.
Logger.hierarchicalLoggingEnabled = true;
Logger.recordStackTraceAtLevel = Level.OFF;
@rockyoung
Copy link
Author

and the hierarchicalLoggingEnabled is designed for "allow fine-grain logging and configuration of loggers in a hierarchy", and when i read the source code at

logging/lib/src/logger.dart

Lines 202 to 206 in 575781e

Logger? target = this;
while (target != null) {
target._publish(record);
target = target.parent;
}

it makes me confused, is that means when child logger is been set level with Level.ALL for example, the LogRecord will published to its parent even though the level of parent logger is Level.OFF? in other word, this behavior does not respect to the level of parent logger.

for the example in the README:

Logger.root.level = Level.ALL; // defaults to Level.INFO
Logger.root.onRecord.listen((record) {
  print('${record.level.name}: ${record.time}: ${record.message}');
});

it makes me to feel like we can control the log "globally" by seting the root level at some point.

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

No branches or pull requests

1 participant