level property
Level
get
level
Effective level considering the levels established in this logger's parents (when hierarchicalLoggingEnabled is true).
Implementation
Level get level {
Level effectiveLevel;
if (parent == null) {
// We're either the root logger or a detached logger. Return our own
// level.
effectiveLevel = _level!;
} else if (!hierarchicalLoggingEnabled) {
effectiveLevel = root._level!;
} else {
effectiveLevel = _level ?? parent!.level;
}
// ignore: unnecessary_null_comparison
assert(effectiveLevel != null);
return effectiveLevel;
}
set
level
(Level? value)
Override the level for this particular Logger and its children.
Setting this to null
makes it inherit the parents level.
Implementation
set level(Level? value) {
if (!hierarchicalLoggingEnabled && parent != null) {
throw UnsupportedError(
'Please set "hierarchicalLoggingEnabled" to true if you want to '
'change the level on a non-root logger.');
}
if (parent == null && value == null) {
throw UnsupportedError(
'Cannot set the level to `null` on a logger with no parent.');
}
final isLevelChanged = _level != value;
_level = value;
if (isLevelChanged) {
_levelChangedController?.add(value);
}
}