level property

Level level

The current logging level for the betrayal scope.

Implementation

static Level get level => _level;
void level=(dynamic level)

Use this to change the logging level betrayal scope.

This is only possible, if hierarchicalLoggingEnabled == true.

If the global isn't in scope, you can call BetrayalLogConfig.allowIndividualLevels instead.

Valid input types are Level, String and num.

String num
ALL 0
FINEST 300
FINER 400
FINE 500
CONFIG 700
INFO 800
WARNING 900
SEVERE 1000
SHOUT 1200
OFF 2000

Implementation

static set level(dynamic level) {
  if (level is Level) {
    _level = level;
  } else if (level is String) {
    level = level.toUpperCase();
    _level = Level.LEVELS.firstWhere(
      (element) => element.name == level,
      orElse: () =>
          throw ArgumentError.value(level, "level", "not a valid Level!"),
    );
  } else if (level is num) {
    // This works assuming that the order will not be changed
    // from lowest value (ALL) to highest (OFF) in the future.
    _level = Level.LEVELS.lastWhere((element) => element.value <= level);
  } else {
    throw ArgumentError(
        "level must be a Level, String or num, not ${level.runtimeType}!");
  }
  _logger.level = _level;

  // Ensure that the following message is logged.
  instance;

  _logger.info("logging level changed to ${_level.name}");
}