summaryrefslogtreecommitdiffstats
path: root/src/log_format.hh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-07 04:48:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-07 04:48:35 +0000
commit207df6fc406e81bfeebdff7f404bd242ff3f099f (patch)
treea1a796b056909dd0a04ffec163db9363a8757808 /src/log_format.hh
parentReleasing progress-linux version 0.11.2-1~progress7.99u1. (diff)
downloadlnav-207df6fc406e81bfeebdff7f404bd242ff3f099f.tar.xz
lnav-207df6fc406e81bfeebdff7f404bd242ff3f099f.zip
Merging upstream version 0.12.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/log_format.hh')
-rw-r--r--src/log_format.hh127
1 files changed, 110 insertions, 17 deletions
diff --git a/src/log_format.hh b/src/log_format.hh
index fdca056..8766558 100644
--- a/src/log_format.hh
+++ b/src/log_format.hh
@@ -108,10 +108,34 @@ enum class value_kind_t : int {
VALUE__MAX
};
+enum class chart_type_t {
+ none,
+ hist,
+ spectro,
+};
+
struct logline_value_meta {
+ struct internal_column {
+ bool operator==(const internal_column&) const { return true; }
+ };
+ struct external_column {
+ bool operator==(const external_column&) const { return true; }
+ };
+ struct table_column {
+ size_t value;
+
+ bool operator==(const table_column& rhs) const
+ {
+ return this->value == rhs.value;
+ }
+ };
+
+ using column_t
+ = mapbox::util::variant<internal_column, external_column, table_column>;
+
logline_value_meta(intern_string_t name,
value_kind_t kind,
- int col = -1,
+ column_t col = external_column{},
const nonstd::optional<log_format*>& format
= nonstd::nullopt)
: lvm_name(name), lvm_kind(kind), lvm_column(col), lvm_format(format)
@@ -132,11 +156,14 @@ struct logline_value_meta {
return *this;
}
+ chart_type_t to_chart_type() const;
+
intern_string_t lvm_name;
value_kind_t lvm_kind;
- int lvm_column{-1};
+ column_t lvm_column{external_column{}};
nonstd::optional<size_t> lvm_values_index;
bool lvm_identifier{false};
+ bool lvm_foreign_key{false};
bool lvm_hidden{false};
nonstd::optional<bool> lvm_user_hidden;
bool lvm_from_module{false};
@@ -254,10 +281,29 @@ struct logline_value_vector {
{
this->lvv_values.clear();
this->lvv_sbr.disown();
+ this->lvv_opid_value = nonstd::nullopt;
+ }
+
+ logline_value_vector() {}
+
+ logline_value_vector(const logline_value_vector& other)
+ : lvv_sbr(other.lvv_sbr.clone()), lvv_values(other.lvv_values),
+ lvv_opid_value(other.lvv_opid_value)
+ {
+ }
+
+ logline_value_vector& operator=(const logline_value_vector& other)
+ {
+ this->lvv_sbr = other.lvv_sbr.clone();
+ this->lvv_values = other.lvv_values;
+ this->lvv_opid_value = other.lvv_opid_value;
+
+ return *this;
}
shared_buffer_ref lvv_sbr;
std::vector<logline_value> lvv_values;
+ nonstd::optional<std::string> lvv_opid_value;
};
struct logline_value_stats {
@@ -284,8 +330,9 @@ struct logline_value_stats {
};
struct logline_value_cmp {
- explicit logline_value_cmp(const intern_string_t* name = nullptr,
- int col = -1)
+ explicit logline_value_cmp(
+ const intern_string_t* name = nullptr,
+ nonstd::optional<logline_value_meta::column_t> col = nonstd::nullopt)
: lvc_name(name), lvc_column(col)
{
}
@@ -297,15 +344,16 @@ struct logline_value_cmp {
if (this->lvc_name != nullptr) {
retval = retval && ((*this->lvc_name) == lv.lv_meta.lvm_name);
}
- if (this->lvc_column != -1) {
- retval = retval && (this->lvc_column == lv.lv_meta.lvm_column);
+ if (this->lvc_column) {
+ retval
+ = retval && (this->lvc_column.value() == lv.lv_meta.lvm_column);
}
return retval;
}
const intern_string_t* lvc_name;
- int lvc_column;
+ nonstd::optional<logline_value_meta::column_t> lvc_column;
};
class log_vtab_impl;
@@ -352,14 +400,6 @@ public:
virtual bool match_name(const std::string& filename) { return true; }
- virtual bool match_mime_type(const file_format_t ff) const
- {
- if (ff == file_format_t::UNKNOWN) {
- return true;
- }
- return false;
- }
-
struct scan_match {
uint32_t sm_quality;
};
@@ -458,6 +498,11 @@ public:
return false;
}
+ virtual std::map<intern_string_t, logline_value_meta> get_field_states()
+ {
+ return {};
+ }
+
const char* const* get_timestamp_formats() const
{
if (this->lf_timestamp_format.empty()) {
@@ -525,6 +570,8 @@ public:
std::string lf_description;
uint8_t lf_mod_index{0};
bool lf_multiline{true};
+ bool lf_structured{false};
+ bool lf_formatted_lines{false};
date_time_scanner lf_date_time;
date_time_scanner lf_time_scanner;
std::vector<pattern_for_lines> lf_pattern_locks;
@@ -544,6 +591,50 @@ public:
std::map<const intern_string_t, std::shared_ptr<format_tag_def>>
lf_tag_defs;
+ std::map<const intern_string_t, std::shared_ptr<format_partition_def>>
+ lf_partition_defs;
+
+ struct opid_descriptor {
+ positioned_property<intern_string_t> od_field;
+ factory_container<lnav::pcre2pp::code> od_extractor;
+ std::string od_prefix{" "};
+ std::string od_suffix;
+ std::string od_joiner{", "};
+
+ nonstd::optional<std::string> matches(const string_fragment& sf) const;
+ };
+
+ struct opid_descriptors {
+ std::shared_ptr<std::vector<opid_descriptor>> od_descriptors;
+
+ std::string to_string(
+ const lnav::map::small<size_t, std::string>& lod) const;
+ };
+
+ std::shared_ptr<std::map<intern_string_t, opid_descriptors>>
+ lf_opid_description_def{
+ std::make_shared<std::map<intern_string_t, opid_descriptors>>()};
+
+ std::shared_ptr<std::map<intern_string_t, opid_descriptors>>
+ lf_subid_description_def{
+ std::make_shared<std::map<intern_string_t, opid_descriptors>>()};
+
+ ArenaAlloc::Alloc<char> lf_desc_allocator{2 * 1024};
+
+ using desc_field_set
+ = robin_hood::unordered_set<intern_string_t,
+ intern_hasher,
+ std::equal_to<intern_string_t>>;
+
+ desc_field_set lf_desc_fields;
+
+ using desc_cap_map
+ = robin_hood::unordered_map<intern_string_t,
+ string_fragment,
+ intern_hasher,
+ std::equal_to<intern_string_t>>;
+ desc_cap_map lf_desc_captures;
+
protected:
static std::vector<std::shared_ptr<log_format>> lf_root_formats;
@@ -563,11 +654,13 @@ protected:
int pf_timestamp_index{-1};
};
- static bool next_format(pcre_format* fmt, int& index, int& locked_index);
+ static bool next_format(const pcre_format* fmt,
+ int& index,
+ int& locked_index);
const char* log_scanf(uint32_t line_number,
string_fragment line,
- pcre_format* fmt,
+ const pcre_format* fmt,
const char* time_fmt[],
struct exttm* tm_out,
struct timeval* tv_out,