diff options
-rw-r--r-- | src/afb-monitor.c | 21 | ||||
-rw-r--r-- | test/monitoring/monitor.html | 1 | ||||
-rw-r--r-- | test/monitoring/monitor.js | 54 |
3 files changed, 41 insertions, 35 deletions
diff --git a/src/afb-monitor.c b/src/afb-monitor.c index 9f01cc02..fd334cf9 100644 --- a/src/afb-monitor.c +++ b/src/afb-monitor.c @@ -66,28 +66,28 @@ static int decode_verbosity(struct json_object *v) int level = -1; if (!wrap_json_unpack(v, "i", &level)) { - level = level < 0 ? 0 : level > 3 ? 3 : level; + level = level < Verbosity_Level_Error ? Verbosity_Level_Error : level > Verbosity_Level_Debug ? Verbosity_Level_Debug : level; } else if (!wrap_json_unpack(v, "s", &s)) { switch(*s&~' ') { case 'D': if (!strcasecmp(s, _debug_)) - level = 3; + level = Verbosity_Level_Debug; break; case 'I': if (!strcasecmp(s, _info_)) - level = 2; + level = Verbosity_Level_Info; break; case 'N': if (!strcasecmp(s, _notice_)) - level = 1; + level = Verbosity_Level_Notice; break; case 'W': if (!strcasecmp(s, _warning_)) - level = 1; + level = Verbosity_Level_Warning; break; case 'E': if (!strcasecmp(s, _error_)) - level = 0; + level = Verbosity_Level_Error; break; } } @@ -155,10 +155,11 @@ static void set_verbosity(struct json_object *spec) static struct json_object *encode_verbosity(int level) { switch(level) { - case 0: return json_object_new_string(_error_); - case 1: return json_object_new_string(_notice_); - case 2: return json_object_new_string(_info_); - case 3: return json_object_new_string(_debug_); + case Verbosity_Level_Error: return json_object_new_string(_error_); + case Verbosity_Level_Warning: return json_object_new_string(_warning_); + case Verbosity_Level_Notice: return json_object_new_string(_notice_); + case Verbosity_Level_Info: return json_object_new_string(_info_); + case Verbosity_Level_Debug: return json_object_new_string(_debug_); default: return json_object_new_int(level); } } diff --git a/test/monitoring/monitor.html b/test/monitoring/monitor.html index e9572ba8..22f090ed 100644 --- a/test/monitoring/monitor.html +++ b/test/monitoring/monitor.html @@ -135,6 +135,7 @@ <span>Verbosity:</span> <select class="select"> <option value="error">error</option> + <option value="warning">warning</option> <option value="notice">notice</option> <option value="info">info</option> <option value="debug">debug</option> diff --git a/test/monitoring/monitor.js b/test/monitoring/monitor.js index bee87e4b..22d71824 100644 --- a/test/monitoring/monitor.js +++ b/test/monitoring/monitor.js @@ -296,32 +296,36 @@ function on_got_apis(obj) { for_all_nodes(api.node, ".trace-box", update_trace_box); } apis[api_name] = api; - get(".desc", api.node).textContent = api_desc.info.description || ""; - _.each(api_desc.paths, function(verb_desc, path_name){ - var verb_name = path_name.substring(1); - var verb = api.verbs[verb_name]; - if (!verb) { - verb = { - node: document.importNode(t_verb, true), - name: verb_name, - api: api - }; - verb.node.VERB = verb; - verb.node.dataset.verb = verb_name; - api.verbs[verb_name] = verb; - get(".name", verb.node).textContent = verb_name; - var g = verb_desc.get ||{}; - var r = g["responses"] || {}; - var t = r["200"] || {}; - var d = t.description || ""; - get(".desc", verb.node).textContent = d; - if (show_perms) { - var p = g["x-permissions"] || ""; - get(".perm", verb.node).textContent = p ? JSON.stringify(p, null, 1) : ""; + if (api_desc == null) { + get(".desc", api.node).textContent = "?? unrecoverable ??"; + } else { + get(".desc", api.node).textContent = api_desc.info.description || ""; + _.each(api_desc.paths, function(verb_desc, path_name){ + var verb_name = path_name.substring(1); + var verb = api.verbs[verb_name]; + if (!verb) { + verb = { + node: document.importNode(t_verb, true), + name: verb_name, + api: api + }; + verb.node.VERB = verb; + verb.node.dataset.verb = verb_name; + api.verbs[verb_name] = verb; + get(".name", verb.node).textContent = verb_name; + var g = verb_desc.get ||{}; + var r = g["responses"] || {}; + var t = r["200"] || {}; + var d = t.description || ""; + get(".desc", verb.node).textContent = d; + if (show_perms) { + var p = g["x-permissions"] || ""; + get(".perm", verb.node).textContent = p ? JSON.stringify(p, null, 1) : ""; + } + api.vnode.append(verb.node); } - api.vnode.append(verb.node); - } - }); + }); + } apis_node.append(api.node); }); inhibit = false; |