-
Notifications
You must be signed in to change notification settings - Fork 3
/
event_severity_constants.e
executable file
·70 lines (56 loc) · 1.69 KB
/
event_severity_constants.e
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
58
59
60
61
62
63
64
65
66
67
68
69
note
component: "Eiffel Object Modelling Framework"
description: "Event logging severity constants"
keywords: "logging"
author: "Thomas Beale"
support: "Ocean Informatics <[email protected]>"
copyright: "Copyright (c) 2005 Ocean Informatics Pty Ltd"
license: "Apache 2.0 License <http://www.apache.org/licenses/LICENSE-2.0.html>"
file: "$URL$"
revision: "$LastChangedRevision$"
last_change: "$LastChangedDate$"
class EVENT_SEVERITY_CONSTANTS
feature -- Access
Default_event_level, Information: INTEGER = 0
Warning: INTEGER = 101
Error: INTEGER = 102
No_events: INTEGER = 110
-- pseudo level (not a severity) for masking all events
Severities: HASH_TABLE[STRING, INTEGER]
once
create Result.make(0)
Result.put("Information", Information)
Result.put("Warning", Warning)
Result.put("Error", Error)
end
Event_levels:HASH_TABLE[INTEGER, STRING]
once
create Result.make(0)
Result.put(Information, "all")
Result.put(Information, "information")
Result.put(Warning, "warning")
Result.put(Error, "error")
Result.put(No_events, "none")
end
event_severity_threshold(a_threshold:STRING):INTEGER
-- send events of this severity and higher to log device; default to all
do
if a_threshold = Void then
Result := Information
else
a_threshold.to_lower
if Event_levels.has(a_threshold) then
Result := Event_levels.item(a_threshold)
else
Result := Default_event_level
end
end
ensure
Validity: is_valid_severity(Result) or else Result = No_events
end
feature -- Status
is_valid_severity(n:INTEGER):BOOLEAN
do
Result := n = Information or else (n >= Warning and n <= Error)
end
end