Redesign message format
[khatus.git] / src / awk / lib / msg_out.awk
1 BEGIN {
2 FS1 = "|" # Fiels separator, level 1 (record to fields)
3 FS2 = ":" # Fiels separator, level 2 (field to subfields
4
5 OFS = FS1
6 Kfs = FS2
7 }
8
9 # -----------------------------------------------------------------------------
10 # alert
11 # -----------------------------------------------------------------------------
12 function msg_out_alert_low(subject, body) {
13 msg_out_alert("low", subject, body)
14 }
15
16 function msg_out_alert_med(subject, body) {
17 msg_out_alert("med", subject, body)
18 }
19
20 function msg_out_alert_hi(subject, body) {
21 msg_out_alert("hi", subject, body)
22 }
23
24 function msg_out_alert(priority, subject, body) {
25 # priority : "low" | "med" | "hi"
26 # subject : string without spaces
27 # body : anything
28 print(Node, Module, "alert", priority, subject, body)
29 }
30
31 # -----------------------------------------------------------------------------
32 # log
33 # -----------------------------------------------------------------------------
34 function msg_out_log_info(location, msg) {
35 msg_out_log("info", location, msg)
36 }
37
38 function msg_out_log_error(location, msg) {
39 msg_out_log("error", location, msg)
40 }
41
42 function msg_out_log(level, location, msg) {
43 print(Node, Module, "log", location, level, msg) > "/dev/stderr"
44 }
45
46 # -----------------------------------------------------------------------------
47 # status_bar
48 # -----------------------------------------------------------------------------
49 function msg_out_status_bar(bar) {
50 print(Node, Module, "status_bar", bar)
51 }
52
53 # -----------------------------------------------------------------------------
54 # data
55 # -----------------------------------------------------------------------------
56 function msg_out_data(key, val) {
57 print(Node, Module, "data", key, val)
58 }
This page took 0.057165 seconds and 4 git commands to generate.