summaryrefslogtreecommitdiffstats
path: root/src/log_format_fwd.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/log_format_fwd.hh')
-rw-r--r--src/log_format_fwd.hh101
1 files changed, 94 insertions, 7 deletions
diff --git a/src/log_format_fwd.hh b/src/log_format_fwd.hh
index 8b9d301..dbcc356 100644
--- a/src/log_format_fwd.hh
+++ b/src/log_format_fwd.hh
@@ -38,19 +38,54 @@
#include "ArenaAlloc/arenaalloc.h"
#include "base/file_range.hh"
+#include "base/map_util.hh"
#include "base/string_attr_type.hh"
#include "byte_array.hh"
#include "log_level.hh"
#include "pcrepp/pcre2pp.hh"
-#include "ptimec.hh"
#include "robin_hood/robin_hood.h"
#include "yajlpp/yajlpp.hh"
class log_format;
+struct log_level_stats {
+ uint32_t lls_error_count{0};
+ uint32_t lls_warning_count{0};
+ uint32_t lls_total_count{0};
+
+ log_level_stats& operator|=(const log_level_stats& rhs);
+ void update_msg_count(log_level_t lvl);
+};
+
+struct log_op_description {
+ nonstd::optional<intern_string_t> lod_id;
+ lnav::map::small<size_t, std::string> lod_elements;
+
+ log_op_description& operator|=(const log_op_description& rhs);
+};
+
+struct opid_sub_time_range {
+ string_fragment ostr_subid;
+ time_range ostr_range;
+ bool ostr_open{true};
+ log_level_stats ostr_level_stats;
+ std::string ostr_description;
+
+ bool operator<(const opid_sub_time_range& rhs) const
+ {
+ return this->ostr_range < rhs.ostr_range;
+ }
+};
+
struct opid_time_range {
- struct timeval otr_begin;
- struct timeval otr_end;
+ time_range otr_range;
+ log_level_stats otr_level_stats;
+ log_op_description otr_description;
+ std::vector<opid_sub_time_range> otr_sub_ops;
+
+ void close_sub_ops(const string_fragment& subid);
+
+ opid_time_range& operator|=(const opid_time_range& rhs);
};
using log_opid_map = robin_hood::unordered_map<string_fragment,
@@ -58,9 +93,25 @@ using log_opid_map = robin_hood::unordered_map<string_fragment,
frag_hasher,
std::equal_to<string_fragment>>;
+using sub_opid_map = robin_hood::unordered_map<string_fragment,
+ string_fragment,
+ frag_hasher,
+ std::equal_to<string_fragment>>;
+
+struct log_opid_state {
+ log_opid_map los_opid_ranges;
+ sub_opid_map los_sub_in_use;
+
+ opid_sub_time_range* sub_op_in_use(ArenaAlloc::Alloc<char>& alloc,
+ log_opid_map::iterator& op_iter,
+ const string_fragment& subid,
+ const timeval& tv,
+ log_level_t level);
+};
+
struct scan_batch_context {
ArenaAlloc::Alloc<char>& sbc_allocator;
- log_opid_map sbc_opids;
+ log_opid_state sbc_opids;
std::string sbc_cached_level_strings[4];
log_level_t sbc_cached_level_values[4];
size_t sbc_cached_level_count{0};
@@ -95,7 +146,7 @@ public:
uint8_t opid = 0)
: ll_offset(off), ll_has_ansi(false), ll_time(t), ll_millis(millis),
ll_opid(opid), ll_sub_offset(0), ll_valid_utf(1), ll_level(lev),
- ll_module_id(mod), ll_expr_mark(0)
+ ll_module_id(mod), ll_meta_mark(0), ll_expr_mark(0)
{
memset(this->ll_schema, 0, sizeof(this->ll_schema));
}
@@ -106,7 +157,8 @@ public:
uint8_t mod = 0,
uint8_t opid = 0)
: ll_offset(off), ll_has_ansi(false), ll_opid(opid), ll_sub_offset(0),
- ll_valid_utf(1), ll_level(lev), ll_module_id(mod), ll_expr_mark(0)
+ ll_valid_utf(1), ll_level(lev), ll_module_id(mod), ll_meta_mark(0),
+ ll_expr_mark(0)
{
this->set_time(tv);
memset(this->ll_schema, 0, sizeof(this->ll_schema));
@@ -175,6 +227,10 @@ public:
bool is_marked() const { return this->ll_level & LEVEL_MARK; }
+ void set_meta_mark(bool val) { this->ll_meta_mark = val; }
+
+ bool is_meta_marked() const { return this->ll_meta_mark; }
+
void set_expr_mark(bool val) { this->ll_expr_mark = val; }
bool is_expr_marked() const { return this->ll_expr_mark; }
@@ -230,6 +286,17 @@ public:
uint8_t get_opid() const { return this->ll_opid; }
+ bool match_opid_hash(unsigned long hash) const
+ {
+ struct {
+ unsigned int value : 6;
+ } reduced = {
+ (unsigned int) hash,
+ };
+
+ return this->ll_opid == reduced.value;
+ }
+
/**
* @return True if there is a schema value set for this log line.
*/
@@ -305,7 +372,8 @@ private:
unsigned int ll_sub_offset : 15;
unsigned int ll_valid_utf : 1;
uint8_t ll_level;
- uint8_t ll_module_id : 7;
+ uint8_t ll_module_id : 6;
+ uint8_t ll_meta_mark : 1;
uint8_t ll_expr_mark : 1;
char ll_schema[2];
};
@@ -327,4 +395,23 @@ struct format_tag_def {
log_level_t ftd_level{LEVEL_UNKNOWN};
};
+struct format_partition_def {
+ explicit format_partition_def(std::string name) : fpd_name(std::move(name))
+ {
+ }
+
+ struct path_restriction {
+ std::string p_glob;
+
+ bool matches(const char* fn) const;
+ };
+
+ std::string fpd_name;
+ std::string fpd_description;
+ std::vector<path_restriction> fpd_paths;
+ factory_container<lnav::pcre2pp::code, int>::with_default_args<PCRE2_DOTALL>
+ fpd_pattern;
+ log_level_t fpd_level{LEVEL_UNKNOWN};
+};
+
#endif