-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlevel.dart
57 lines (39 loc) · 1.41 KB
/
level.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/// 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 = Level('all', 0);
/// Special key to turn off all logging ([value] = 2000).
static const Level off = Level('off', 2000);
static const Level verbose = Level('verbose', 300);
static const Level debug = Level('debug', 500);
static const Level info = Level('info', 800);
static const Level warning = Level('warning', 900);
static const Level error = Level('error', 1000);
static const List<Level> levels = [
all,
verbose,
debug,
info,
warning,
error,
off,
];
@override
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;
@override
int compareTo(Level other) => value - other.value;
@override
int get hashCode => value;
@override
String toString() => name;
}