# # # # log_format_labels_util.cfv # # get_log_format_item_labels_dat() # get_log_format_item_dat() # # include "templates.util.encoding"; include "templates.util.log_format_util"; # # # # get_log_format_labels_dat() # # # subroutine(get_log_format_item_labels_dat( node log_format, bool add_device_name_labels), ( debug_message("#### get_log_format_item_labels_dat()\n"); # This returns one or more labels of the given log format. Log formats may contain # multiple labels defined in the info node. If multiple labels exist then the client # should display all of them, though each label refer to the same log format plug-in. string labels_dat = "["; string label; node log_format_info_labels = get_log_format_labels_from_log_format_info(log_format, add_device_name_labels); if (num_subnodes(log_format_info_labels) > 0) then ( node item; foreach item log_format_info_labels ( label = @item; labels_dat .= '"' . encode_json(label) . '",'; ); labels_dat = replace_last(labels_dat, ",", "]"); ) else ( # Add regular log format plugin label label = encode_json(@(log_format . ".log.format.format_label")); labels_dat = '["' . label . '"]'; ); # return labels_dat; )); # # # # get_log_format_item_dat() # # # subroutine(get_log_format_item_dat( node log_format, bool add_device_name_labels), ( debug_message("#### get_log_format_item_dat() \n"); string log_format_name = node_name(log_format); # string log_format_label = node_value(subnode_by_name(log_format, "log.format.format_label")); string log_format_labels_dat = get_log_format_item_labels_dat(log_format, add_device_name_labels); string log_format_description = if (?(log_format . ".log.format.description")) then (@(log_format . ".log.format.description")) else (""); string log_format_type = node_value(subnode_by_name(log_format, "log.miscellaneous.log_data_type")); debug_message("#### log_format_name: " . log_format_name . "\n"); string not_supported_message; if (?(log_format . ".create_profile_wizard_options.not_supported_message")) then ( not_supported_message = expand(@(log_format . ".create_profile_wizard_options.not_supported_message")); ); # debug_message("#### not_supported_message: " . not_supported_message . "\n"); bool is_supported_log_format = (not_supported_message eq ""); string dat = "{"; dat .= add_json("name", log_format_name, "string"); # KHP 27/Sep/2010 - replaced "label" with "labels" (one or more labels are possible per format) # dat .= add_json("label", log_format_label, "string"); dat .= add_json("labels", log_format_labels_dat, "obj"); dat .= add_json("description", log_format_description, "string"); dat .= add_json("type", log_format_type, "string"); dat .= add_json("isSupportedLogFormat", is_supported_log_format, "bool"); dat .= add_json("notSupportedMessage", not_supported_message, "string"); dat = close_json(dat); dat; ));