Dart DocumentationloggingLevel

Level class

Levels to control logging output. Logging can be enabled to include all levels above certain Level. Levels are ordered using an integer value Level.value. The predefined Level constants below are sorted as follows (in descending order): Level.SHOUT, Level.SEVERE, Level.WARNING, Level.INFO, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, and Level.ALL.

We recommend using one of the predefined logging levels. If you define your own level, make sure you use a value between those used in Level.ALL and Level.OFF.

class Level implements Comparable<Level> {

 final String name;

 /**
  * Unique value for this level. Used to order levels, so filtering can exclude
  * messages whose level is under certain value.
  */
 final int value;

 const Level(this.name, this.value);

 /** Special key to turn on logging for all levels ([value] = 0). */
 static const Level ALL = const Level('ALL', 0);

 /** Special key to turn off all logging ([value] = 2000). */
 static const Level OFF = const Level('OFF', 2000);

 /** Key for highly detailed tracing ([value] = 300). */
 static const Level FINEST = const Level('FINEST', 300);

 /** Key for fairly detailed tracing ([value] = 400). */
 static const Level FINER = const Level('FINER', 400);

 /** Key for tracing information ([value] = 500). */
 static const Level FINE = const Level('FINE', 500);

 /** Key for static configuration messages ([value] = 700). */
 static const Level CONFIG = const Level('CONFIG', 700);

 /** Key for informational messages ([value] = 800). */
 static const Level INFO = const Level('INFO', 800);

 /** Key for potential problems ([value] = 900). */
 static const Level WARNING = const Level('WARNING', 900);

 /** Key for serious failures ([value] = 1000). */
 static const Level SEVERE = const Level('SEVERE', 1000);

 /** Key for extra debugging loudness ([value] = 1200). */
 static const Level SHOUT = const Level('SHOUT', 1200);

 static const List<Level> LEVELS = const
     [ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, SHOUT, OFF];

 bool operator ==(Object other) => other is Level && value == other.value;
 bool operator <(Level other) => value < other.value;
 bool operator <=(Level other) => value <= other.value;
 bool operator >(Level other) => value > other.value;
 bool operator >=(Level other) => value >= other.value;
 int compareTo(Level other) => value - other.value;
 int get hashCode => value;
 String toString() => name;
}

Implements

Comparable<Level>

Static Properties

const Level ALL #

Special key to turn on logging for all levels (value = 0).

static const Level ALL = const Level('ALL', 0)

const Level CONFIG #

Key for static configuration messages (value = 700).

static const Level CONFIG = const Level('CONFIG', 700)

const Level FINE #

Key for tracing information (value = 500).

static const Level FINE = const Level('FINE', 500)

const Level FINER #

Key for fairly detailed tracing (value = 400).

static const Level FINER = const Level('FINER', 400)

const Level FINEST #

Key for highly detailed tracing (value = 300).

static const Level FINEST = const Level('FINEST', 300)

const Level INFO #

Key for informational messages (value = 800).

static const Level INFO = const Level('INFO', 800)

const List<Level> LEVELS #

static const List<Level> LEVELS = const
   [ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, SHOUT, OFF]

const Level OFF #

Special key to turn off all logging (value = 2000).

static const Level OFF = const Level('OFF', 2000)

const Level SEVERE #

Key for serious failures (value = 1000).

static const Level SEVERE = const Level('SEVERE', 1000)

const Level SHOUT #

Key for extra debugging loudness (value = 1200).

static const Level SHOUT = const Level('SHOUT', 1200)

const Level WARNING #

Key for potential problems (value = 900).

static const Level WARNING = const Level('WARNING', 900)

Constructors

const Level(String name, int value) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
const Level(this.name, this.value);

Properties

final int hashCode #

Get a hash code for this object.

All objects have hash codes. Hash codes are guaranteed to be the same for objects that are equal when compared using the equality operator ==. Other than that there are no guarantees about the hash codes. They will not be consistent between runs and there are no distribution guarantees.

If a subclass overrides hashCode it should override the equality operator as well to maintain consistency.

docs inherited from Object
int get hashCode => value;

final String name #

final String name

final int value #

Unique value for this level. Used to order levels, so filtering can exclude messages whose level is under certain value.

final int value

Operators

bool operator <(Level other) #

bool operator <(Level other) => value < other.value;

bool operator <=(Level other) #

bool operator <=(Level other) => value <= other.value;

bool operator >(Level other) #

bool operator >(Level other) => value > other.value;

bool operator >=(Level other) #

bool operator >=(Level other) => value >= other.value;

bool operator ==(Object other) #

The equality operator.

The default behavior for all Objects is to return true if and only if this and other are the same object.

Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:

  • Total: It must return a boolean for all arguments. It should never throw or return null.

  • Reflexive: For all objects o, o == o must be true.

  • Symmetric: For all objects o1 and o2, o1 == o2 and o2 == o1 must either both be true, or both be false.

  • Transitive: For all objects o1, o2, and o3, if o1 == o2 and o2 == o3 are true, then o1 == o3 must be true.

The method should also be consistent over time, so equality of two objects should not change over time, or at least only change if one of the objects was modified.

If a subclass overrides the equality operator it should override the hashCode method as well to maintain consistency.

docs inherited from Object
bool operator ==(Object other) => other is Level && value == other.value;

Methods

int compareTo(Level other) #

Compares this object to another Comparable

Returns a value like a Comparator when comparing this to other.

May throw an ArgumentError if other is of a type that is not comparable to this.

docs inherited from Comparable<Level>
int compareTo(Level other) => value - other.value;

String toString() #

Returns a string representation of this object.

docs inherited from Object
String toString() => name;