{= # include "templates.shared.util.int_string_to_char"; include "templates.shared.util.get_licensing_features"; string autodetecting_id = volatile.autodetecting_id; # check features (lite | pro | enterprise) string licensing_features = get_licensing_features(); # ----------------- # detect log format # ----------------- debug_message("\n\n\n@@@@ detect_log_format.cfv START \n"); debug_message("log source:\n" . node_as_string("volatile.new_profile.log_source") . "\n"); # Autodetect the log format of the data at volatile.new_profile.log_source, # and put the result in volatile.autodetected_formats. # decode any "__HexEsc__" values in log source node node item; string item_value; foreach item "volatile.new_profile.log_source.0" ( item_value = node_value(item); if (contains(item_value, "__HexEsc__")) then ( if (contains(item_value, "__HexEsc__2B")) then ( item_value = replace_all(item_value, "__HexEsc__2B", "+"); ); if (contains(item_value, "__HexEsc__5C")) then ( item_value = replace_all(item_value, "__HexEsc__5C", "\\"); ); if (contains(item_value, "__HexEsc__24")) then ( item_value = replace_all(item_value, "__HexEsc__24", "$"); ); "volatile.new_profile.log_source.0." . node_name(item) = item_value; ); ); debug_message("log source 2:\n" . node_as_string("volatile.new_profile.log_source") . "\n"); # if the log_source type is "local" decode the pathname and convert UTF-8 to local code page if (node_value("volatile.new_profile.log_source.0.type") eq "local") then ( string pathname = node_value("volatile.new_profile.log_source.0.pathname"); # decoding is already done above! # pathname = replace_all(pathname, "__HexEsc__24", "$"); # pathname = replace_all(pathname, "__HexEsc__5C", "\\"); volatile.new_profile.log_source.0.pathname = convert_utf8_to_local_code_page(pathname); ); debug_message("\n\n@@@@ @@@@ autodetect_log_format START\n"); autodetect_log_format("volatile.new_profile.log_source", "volatile.autodetected_formats", autodetecting_id); debug_message("\n\n@@@@ @@@@ autodetect_log_format END\n"); # If the log source was invalid, generate an error message. The text of the error message # is in volatile.error_message. bool invalid_log_source = node_value("volatile.invalid_log_source"); debug_message("#### invalid_log_source: " . invalid_log_source . "\n"); if (!invalid_log_source) then ( # ---------------- # valid log source # ---------------- debug_message("\n\n\nAutodetected log formats:\n" . node_as_string("volatile.autodetected_formats") . "\n"); # Lite cleanup from Beta log formats if (licensing_features eq "lite" and node_exists("volatile.autodetected_formats") and (num_subnodes("volatile.autodetected_formats") > 0)) then ( # remove any Beta log format in Lite version node item; string log_format_name; string plugin_version; foreach item "volatile.autodetected_formats" ( log_format_name = node_value(item); plugin_version = ""; if (node_exists("log_formats." . log_format_name . ".plugin_version")) then ( plugin_version = lowercase(node_value("log_formats." . log_format_name . ".plugin_version")); ); if (starts_with(log_format_name, "beta_") or contains(plugin_version, "beta")) then ( delete_node(item); ); ); debug_message("\n\n\nAutodetected log formats in Lite after cleanup from BETA log formats:\n" . node_as_string("volatile.autodetected_formats") . "\n"); ); if (!node_exists("volatile.autodetected_formats") or (num_subnodes("volatile.autodetected_formats") == 0)) then ( volatile.autodetected_formats = false; ); # clone the node and save it in TemporaryFiles clone_node("volatile.autodetected_formats", "TemporaryFiles." . autodetecting_id); ) else ( # ------------------ # invalid log source # ------------------ # Note, we save the error message in TemporaryFiles in the same node # as we would have saved autodetected formats! string msg = "-"; if (node_exists("volatile.error_message")) then ( msg = volatile.error_message; ); "TemporaryFiles." . autodetecting_id . ".error_message" = msg; debug_message("#### log source error message:\n" . node_as_string("volatile.error_message") . "\n\n"); ); save_node("TemporaryFiles." . autodetecting_id); =}