From 207df6fc406e81bfeebdff7f404bd242ff3f099f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 7 May 2024 06:48:35 +0200 Subject: Merging upstream version 0.12.2. Signed-off-by: Daniel Baumann --- src/all_logs_vtab.cc | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/all_logs_vtab.cc') diff --git a/src/all_logs_vtab.cc b/src/all_logs_vtab.cc index f4468a6..69acf49 100644 --- a/src/all_logs_vtab.cc +++ b/src/all_logs_vtab.cc @@ -31,15 +31,22 @@ #include "base/attr_line.hh" #include "config.h" +#include "data_parser.hh" +#include "elem_to_json.hh" static auto intern_lifetime = intern_string::get_table_lifetime(); all_logs_vtab::all_logs_vtab() : log_vtab_impl(intern_string::lookup("all_logs")), - alv_msg_meta( - intern_string::lookup("log_msg_format"), value_kind_t::VALUE_TEXT, 0), - alv_schema_meta( - intern_string::lookup("log_msg_schema"), value_kind_t::VALUE_TEXT, 1) + alv_msg_meta(intern_string::lookup("log_msg_format"), + value_kind_t::VALUE_TEXT, + logline_value_meta::table_column{0}), + alv_schema_meta(intern_string::lookup("log_msg_schema"), + value_kind_t::VALUE_TEXT, + logline_value_meta::table_column{1}), + alv_values_meta(intern_string::lookup("log_msg_values"), + value_kind_t::VALUE_JSON, + logline_value_meta::table_column{2}) { this->alv_msg_meta.lvm_identifier = true; this->alv_schema_meta.lvm_identifier = true; @@ -57,6 +64,11 @@ all_logs_vtab::get_columns(std::vector& cols) const "", true, "The ID for the message schema"); + cols.emplace_back(this->alv_values_meta.lvm_name.get(), + SQLITE3_TEXT, + "", + false, + "The values extracted from the message"); } void @@ -70,7 +82,7 @@ all_logs_vtab::extract(logfile* lf, logline_value_vector sub_values; this->vi_attrs.clear(); - sub_values.lvv_sbr = line; + sub_values.lvv_sbr = line.clone(); format->annotate(line_number, this->vi_attrs, sub_values, false); auto body = find_string_attr_range(this->vi_attrs, &SA_BODY); @@ -87,9 +99,18 @@ all_logs_vtab::extract(logfile* lf, dp.dp_msg_format = &str; dp.parse(); + yajlpp_gen gen; + yajl_gen_config(gen, yajl_gen_beautify, false); + + elements_to_json(gen, dp, &dp.dp_pairs); + values.lvv_values.emplace_back(this->alv_msg_meta, std::move(str)); values.lvv_values.emplace_back(this->alv_schema_meta, dp.dp_schema_id.to_string()); + values.lvv_values.emplace_back( + this->alv_values_meta, + json_string(gen).to_string_fragment().to_string()); + values.lvv_opid_value = std::move(sub_values.lvv_opid_value); } bool -- cgit v1.2.3