# # # # log_format_labels_util.cfv # # get_log_format_item_labels_dat() # get_missing_log_fields_warning() # 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), ( 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); 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 if (?(log_format . ".log.format.format_label") and @(log_format . ".log.format.format_label") ne "") then ( label = @(log_format . ".log.format.format_label"); ); else ( label = "(unknown) - " . node_name(log_format); ); labels_dat = '["' . encode_json(label) . '"]'; ); # return labels_dat; )); # # # get_missing_log_fields_warning() # # # subroutine(get_missing_log_fields_warning( node log_format), ( # Returns any missing log fields of log data for which a warning must be shown. debug_message("\n\n#### get_missing_log_fields_warning() \n"); debug_message("#### log format node name: " . node_name(log_format) . "\n"); debug_message("#### the log_format:\n" . node_as_string(log_format) . "\n\n\n"); string missing_log_fields = "["; if (?(log_format . ".create_profile_wizard_options.warn_on_missing_log_fields") and num_subnodes(log_format . ".create_profile_wizard_options.warn_on_missing_log_fields") > 0) then ( node warn_on_missing_log_fields = log_format . ".create_profile_wizard_options.warn_on_missing_log_fields"; node detected_log_fields; if (?(log_format . ".log.fields")) then ( detected_log_fields = log_format . ".log.fields"; ) else ( detected_log_fields = new_node(); ); # Get the missing log fields node item; string log_field_name; foreach item warn_on_missing_log_fields ( log_field_name = node_name(item); if (!detected_log_fields?{log_field_name}) then ( missing_log_fields .= '"' . encode_json(log_field_name) . '",'; ); ); ); if (missing_log_fields eq "[") then ( missing_log_fields .= "]"; ) else ( missing_log_fields = replace_last(missing_log_fields, ",", "]"); ); debug_message("#### missing_log_fields: " . missing_log_fields . "\n"); # Return missing_log_fields; )); # # # get_log_format_item_dat() # # subroutine(get_log_format_item_dat( node log_format), ( debug_message("#### get_log_format_item_dat() \n"); string log_format_name = node_name(log_format); debug_message("#### log_format_name: " . log_format_name . "\n"); # 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); string log_format_description = if (?(log_format . ".log.format.description")) then (@(log_format . ".log.format.description")) else (""); string log_data_type; string log_format_type; if (?(log_format . ".log.miscellaneous.log_data_type")) then ( log_data_type = @(log_format . ".log.miscellaneous.log_data_type"); ); if (?(log_format . ".log.miscellaneous.log_format_type")) then ( log_format_type = @(log_format . ".log.miscellaneous.log_format_type"); ); # if (?log_format . "log.miscellaneous.log_format_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 ""); # KHP 10/02/2014 - Added missing log fields warning # bool is_warn_on_missing_log_fields = false; # string missing_log_fields_warning = get_missing_log_fields_warning(log_format); # KHP - 22/May/2014 removed missing_log_fields_warning # string missing_log_fields_warning = "[]"; 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_data_type, "string"); # KHP 12/Feb/2012 - Added log_format_type, required to create meta type label # which consists of log_data_type and log_format_type. dat .= add_json("lfType", log_format_type, "string"); dat .= add_json("isSupportedLogFormat", is_supported_log_format, "bool"); dat .= add_json("notSupportedMessage", not_supported_message, "string"); # dat .= add_json("isWarnOnMissingLogFields", is_warn_on_missing_log_fields, "bool"); # dat .= add_json("missingLogFieldsWarning", missing_log_fields_warning, "obj"); dat = close_json(dat); dat; ));