Redesign message format
[khatus.git] / src / awk / lib / msg_in.awk
1 BEGIN {
2 FS1 = "|" # Fiels separator, level 1 (record to fields)
3 FS2 = ":" # Fiels separator, level 2 (field to subfields)
4
5 FS = FS1
6 Kfs = FS2
7 }
8
9 function msg_in_parse(msg, line, fields, type) {
10 split(line, fields, FS1)
11 msg["node"] = fields[1]
12 msg["module"] = fields[2]
13 type = fields[3]
14 msg["type"] = type
15
16 if (type == "data") {
17 msg["key"] = fields[4]
18 msg["val"] = str_tail(str_join(fields, 1, 4, FS1) FS1, line)
19 } else if (type == "error") {
20 msg["line"] = str_tail(str_join(fields, 1, 3, FS1) FS1, line)
21 } else if (type == "alert") {
22 msg["priority"] = fields[4]
23 msg["subject"] = fields[5]
24 msg["body"] = str_tail(str_join(fields, 1, 5, FS1) FS1, line)
25 } else if (type == "log") {
26 msg["location"] = fields[4]
27 msg["level"] = fields[5]
28 msg["msg"] = str_tail(str_join(fields, 1, 5, FS1) FS1, line)
29 } else if (type == "status_bar") {
30 msg["status_bar"] = str_tail(str_join(fields, 1, 3, FS1) FS1, line)
31 } else {
32 msg_out_log_error(\
33 "msg_in_parse",
34 "Unexpected msg type: " type " in given input line: " line \
35 )
36 exit 1
37 }
38 }
This page took 0.050966 seconds and 4 git commands to generate.