mirror of
https://github.com/tstack/lnav.git
synced 2024-08-17 00:40:30 +03:00
[filter] fix for multiple filter-ins being applied
This commit is contained in:
parent
99f34a1447
commit
c2e44c5998
@ -457,7 +457,8 @@ bool logfile_sub_source::rebuild_index(bool force)
|
||||
|
||||
this->lss_filtered_index.reserve(this->lss_index.size());
|
||||
|
||||
uint32_t enabled_mask = this->get_filters().get_enabled_mask();
|
||||
uint32_t filter_in_mask, filter_out_mask;
|
||||
this->get_filters().get_enabled_mask(filter_in_mask, filter_out_mask);
|
||||
|
||||
for (size_t index_index = start_size;
|
||||
index_index < this->lss_index.size();
|
||||
@ -466,7 +467,8 @@ bool logfile_sub_source::rebuild_index(bool force)
|
||||
uint64_t line_number;
|
||||
logfile_data *ld = this->find_data(cl, line_number);
|
||||
|
||||
if (!ld->ld_filter_state.excluded(enabled_mask, line_number) &&
|
||||
if (!ld->ld_filter_state.excluded(filter_in_mask, filter_out_mask,
|
||||
line_number) &&
|
||||
(*(ld->get_file()->begin() + line_number)).get_msg_level() >=
|
||||
this->lss_min_log_level) {
|
||||
this->lss_filtered_index.push_back(index_index);
|
||||
@ -574,7 +576,9 @@ void logfile_sub_source::text_filters_changed()
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t enabled_mask = this->get_filters().get_enabled_mask();
|
||||
uint32_t filtered_in_mask, filtered_out_mask;
|
||||
|
||||
this->get_filters().get_enabled_mask(filtered_in_mask, filtered_out_mask);
|
||||
|
||||
this->lss_filtered_index.clear();
|
||||
for (size_t index_index = 0; index_index < this->lss_index.size(); index_index++) {
|
||||
@ -582,7 +586,8 @@ void logfile_sub_source::text_filters_changed()
|
||||
uint64_t line_number;
|
||||
logfile_data *ld = this->find_data(cl, line_number);
|
||||
|
||||
if (!ld->ld_filter_state.excluded(enabled_mask, line_number) &&
|
||||
if (!ld->ld_filter_state.excluded(filtered_in_mask, filtered_out_mask,
|
||||
line_number) &&
|
||||
(*(ld->get_file()->begin() + line_number)).get_msg_level() >=
|
||||
this->lss_min_log_level) {
|
||||
this->lss_filtered_index.push_back(index_index);
|
||||
|
@ -93,8 +93,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool excluded(uint32_t enabled_mask, size_t offset) const {
|
||||
return (this->lfo_filter_state.tfs_mask[offset] & enabled_mask) != 0;
|
||||
bool excluded(uint32_t filter_in_mask, uint32_t filter_out_mask,
|
||||
size_t offset) const {
|
||||
bool filtered_in = (filter_in_mask == 0) || (
|
||||
this->lfo_filter_state.tfs_mask[offset] & filter_in_mask) != 0;
|
||||
bool filtered_out = (
|
||||
this->lfo_filter_state.tfs_mask[offset] & filter_out_mask) != 0;
|
||||
return !filtered_in || filtered_out;
|
||||
};
|
||||
|
||||
size_t get_min_count(size_t max) const {
|
||||
|
@ -130,20 +130,7 @@ public:
|
||||
void end_of_message(logfile_filter_state &lfs) {
|
||||
uint32_t mask = 0;
|
||||
|
||||
switch (this->get_type()) {
|
||||
case INCLUDE:
|
||||
if (!this->lf_message_matched) {
|
||||
mask = ((uint32_t) 1) << this->lf_index;
|
||||
}
|
||||
break;
|
||||
case EXCLUDE:
|
||||
if (this->lf_message_matched) {
|
||||
mask = ((uint32_t) 1) << this->lf_index;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mask = ((uint32_t) this->lf_message_matched ? 1U : 0) << this->lf_index;
|
||||
|
||||
for (size_t lpc = 0; lpc < this->lf_lines_for_message; lpc++) {
|
||||
size_t line_number = lfs.tfs_filter_count[this->lf_index];
|
||||
@ -248,16 +235,26 @@ public:
|
||||
return retval;
|
||||
};
|
||||
|
||||
uint32_t get_enabled_mask() {
|
||||
uint32_t retval = 0;
|
||||
|
||||
void get_enabled_mask(uint32_t &filter_in_mask, uint32_t &filter_out_mask) {
|
||||
filter_in_mask = filter_out_mask = 0;
|
||||
for (iterator iter = this->begin(); iter != this->end(); ++iter) {
|
||||
if ((*iter)->is_enabled()) {
|
||||
retval |= (1L << (*iter)->get_index());
|
||||
text_filter *tf = (*iter);
|
||||
if (tf->is_enabled()) {
|
||||
uint32_t bit = (1UL << tf->get_index());
|
||||
|
||||
switch (tf->get_type()) {
|
||||
case text_filter::EXCLUDE:
|
||||
filter_out_mask |= bit;
|
||||
break;
|
||||
case text_filter::INCLUDE:
|
||||
filter_in_mask |= bit;
|
||||
break;
|
||||
default:
|
||||
ensure(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -210,6 +210,7 @@ dist_noinst_DATA = \
|
||||
logfile_access_log.0 \
|
||||
logfile_access_log.1 \
|
||||
logfile_empty.0 \
|
||||
logfile_filter.0 \
|
||||
logfile_for_join.0 \
|
||||
logfile_generic.0 \
|
||||
logfile_glog.0 \
|
||||
|
@ -792,6 +792,7 @@ dist_noinst_DATA = \
|
||||
logfile_access_log.0 \
|
||||
logfile_access_log.1 \
|
||||
logfile_empty.0 \
|
||||
logfile_filter.0 \
|
||||
logfile_for_join.0 \
|
||||
logfile_generic.0 \
|
||||
logfile_glog.0 \
|
||||
|
@ -109,6 +109,27 @@ check_output "filter-out append is not working" <<EOF
|
||||
EOF
|
||||
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":filter-in avahi" \
|
||||
-c ":filter-in dnsmasq" \
|
||||
${test_dir}/logfile_filter.0
|
||||
|
||||
check_output "multiple filter-in is not working" <<EOF
|
||||
Dec 6 13:01:34 ubu-mac avahi-daemon[786]: Joining mDNS multicast group on interface virbr0.IPv4 with address 192.168.122.1.
|
||||
Dec 6 13:01:34 ubu-mac avahi-daemon[786]: New relevant interface virbr0.IPv4 for mDNS.
|
||||
Dec 6 13:01:34 ubu-mac avahi-daemon[786]: Registering new address record for 192.168.122.1 on virbr0.IPv4.
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq[1840]: started, version 2.68 cachesize 150
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq[1840]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq-dhcp[1840]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq-dhcp[1840]: DHCP, sockets bound exclusively to interface virbr0
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq[1840]: reading /etc/resolv.conf
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq[1840]: using nameserver 192.168.1.1#53
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq[1840]: read /etc/hosts - 5 addresses
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq[1840]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
|
||||
Dec 6 13:01:34 ubu-mac dnsmasq-dhcp[1840]: read /var/lib/libvirt/dnsmasq/default.hostsfile
|
||||
EOF
|
||||
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":switch-to-view help" \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
Loading…
Reference in New Issue
Block a user