1 module Time = Khatus_time
4 | Alert of {priority : [`low | `med | `hi]; subject : string; body : string}
5 | Data of {key : string list; value : string}
14 | Log of {location : string; level : [`info | `error]; msg : string}
15 | Status_bar of string
18 {node : string; modul : string; content : content}
23 let to_string {node; modul; content} =
25 | Alert {priority; subject; body} ->
32 String.concat sep_1 [node; modul; "alert"; priority; subject; body]
33 | Data {key; value} ->
34 let key = String.concat sep_2 key in
35 String.concat sep_1 [node; modul; "data"; key; value]
36 | Cache {mtime; node=node'; modul=modul'; key; value} ->
37 let key = String.concat sep_2 key in
38 let mtime = Time.to_string mtime in
41 [node; modul; "cache"; mtime; node'; modul'; key; value]
43 String.concat sep_1 [node; modul; "error"; text]
44 | Log {location; level; msg} ->
50 String.concat sep_1 [node; modul; "log"; location; level; msg]
52 String.concat sep_1 [node; modul; "status_bar"; text]
54 let next_time t ~node ~time:time0 =
56 | { modul = "khatus_sensor_datetime"
57 ; content = Data {key = ["epoch"]; value = time1}
59 } when node' = node ->
60 (* TODO: Going forawrd, perhaps throwing exceptions is the wrong way. *)
61 (* TODO: Should we check this one at msg parse time? *)
63 | {content = Data _; _}
64 | {content = Alert _; _}
65 | {content = Cache _; _}
66 | {content = Error _; _}
67 | {content = Log _; _}
68 | {content = Status_bar _; _}