-
Notifications
You must be signed in to change notification settings - Fork 1
/
journal.krl
53 lines (47 loc) · 1 KB
/
journal.krl
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
ruleset journal {
meta {
shares __testing, getEntries
}
global {
__testing = { "queries":
[ { "name": "__testing" }
, {"name": "getEntries"}
] , "events":
[ { "domain": "journal", "type": "new_entry", "attrs": ["message"] }
, { "domain": "journal", "type": "new_entry" }
, { "domain": "journal", "type": "restart" }
]
}
getEntries = function() {
ent:entries
}
}
rule init {
select when wrangler ruleset_added where rids >< meta:rid
pre {
}
always {
ent:entries := []
}
}
rule set {
select when journal new_entry
pre {
message = event:attrs{"message"}
time = time:now()
entry = {"timestamp": time, "message": message}
}
if message then send_directive("New Journal Entry")
fired {
ent:entries := ent:entries.append(entry)
}
}
rule restart {
select when journal restart
pre {
}
always {
ent:entries := []
}
}
}