Exemplo n.º 1
0
        private bool matches_case_insensitive(line l)
        {
            Debug.Assert(part != part_type.font);
            string line_part = this.line_part(l).ToLower();

            return(compare(line_part, lo_text, lo_words));
        }
Exemplo n.º 2
0
        private line parse_relative_line(string l, ulong pos_in_log)
        {
            List <Tuple <int, int> > indexes = new List <Tuple <int, int> >();

            for (int i = 0; i < (int)info_type.max; ++i)
            {
                indexes.Add(new Tuple <int, int>(-1, -1));
            }

            int cur_idx       = 0;
            int correct_count = 0;

            foreach (var rel in relative_idx_in_line_)
            {
                if (cur_idx < 0)
                {
                    break;
                }
                var index = parse_relative_part(l, rel, ref cur_idx);
                if (index.Item1 >= 0 && index.Item2 >= 0)
                {
                    indexes[(int)rel.type] = index;
                    ++correct_count;
                }
            }

            // if we could parse time or date, we consider it an OK line
            bool normal_line = correct_count == relative_idx_in_line_.Count;
            line new_        = new line(pos_in_log, l, normal_line ? indexes.ToArray() : line_contains_msg_only_);

            return(new_);
        }
Exemplo n.º 3
0
        private string line_part(line l)
        {
            string sub = "";

            switch (part)
            {
            case part_type.date:
                sub = l.part(info_type.date);
                break;

            case part_type.time:
                sub = l.part(info_type.time);
                break;

            case part_type.level:
                sub = l.part(info_type.level);
                break;

            case part_type.message:
                sub = l.part(info_type.msg);
                break;

            case part_type.file:
                sub = l.part(info_type.file);
                break;

            case part_type.func:
                sub = l.part(info_type.func);
                break;

            case part_type.class_:
                sub = l.part(info_type.class_);
                break;

            case part_type.ctx1:
                sub = l.part(info_type.ctx1);
                break;

            case part_type.ctx2:
                sub = l.part(info_type.ctx2);
                break;

            case part_type.ctx3:
                sub = l.part(info_type.ctx3);
                break;

            case part_type.thread:
                sub = l.part(info_type.thread);
                break;

            default:
                Debug.Assert(false);
                break;
            }
            return(sub);
        }
Exemplo n.º 4
0
 public override line line_at(int idx) {
     lock (this) {
         if (idx < entries_.Count) {
             var entry = entries_[idx];
             var l = new line( new sub_string(string_, idx), entry.idx_in_line(aliases), entry.time );
             return l;
         } else {
             // this can happen, when the log has been re-written, and everything is being refreshed
             throw new line.exception("invalid line request " + idx + " / " + entries_.Count);
         }
     }
 }
Exemplo n.º 5
0
        private line parse_line(string l, ulong pos_in_log)
        {
            if (relative_syntax_)
            {
                return(parse_relative_line(l, pos_in_log));
            }

            try {
                bool normal_line = parse_time(l, idx_in_line_[(int)info_type.time]) && parse_date(l, idx_in_line_[(int)info_type.date]);
                if (idx_in_line_[(int)info_type.time].Item1 < 0 && idx_in_line_[(int)info_type.date].Item1 < 0)
                {
                    // in this case, we don't have time & date - see that the level matches
                    // note: we can't rely on level too much, since the user might have additional levels that our defaults - so we could get false negatives
                    normal_line = parse_level(l, idx_in_line_[(int)info_type.level]);
                }

                line new_ = new line(pos_in_log, l, normal_line ? idx_in_line_ : line_contains_msg_only_);
                return(new_);
            } catch (Exception e) {
                logger.Error("invalid line: " + l);
                return(new line(pos_in_log, l, line_contains_msg_only_));
            }
        }
Exemplo n.º 6
0
 public match_item(BitArray matches, font_info font, line line, int line_idx, log_view parent) : base(matches, font, line, line_idx) {
 }
Exemplo n.º 7
0
 public bool matches(line l)
 {
     return(case_sensitive ? matches_case_sensitive(l) : matches_case_insensitive(l));
 }
Exemplo n.º 8
0
        private line parse_relative_line(string l, ulong pos_in_log)
        {
            List< Tuple<int,int> > indexes = new List<Tuple<int, int>>();
            for ( int i = 0; i < (int)info_type.max; ++i)
                indexes.Add(new Tuple<int,int>(-1,-1));

            int cur_idx = 0;
            int correct_count = 0;
            foreach (var rel in relative_idx_in_line_) {
                if (cur_idx < 0)
                    break;
                var index = parse_relative_part(l, rel, ref cur_idx);
                if (index.Item1 >= 0 && index.Item2 >= 0) {
                    indexes[(int) rel.type] = index;
                    ++correct_count;
                }
            }

            // if we could parse time or date, we consider it an OK line
            bool normal_line = correct_count == relative_idx_in_line_.Count;
            line new_ = new line(pos_in_log, l, normal_line ? indexes.ToArray() : line_contains_msg_only_);
            return new_;
        }
Exemplo n.º 9
0
        private line parse_line(string l, ulong pos_in_log)
        {
            if (relative_syntax_)
                return parse_relative_line(l, pos_in_log);

            try {
                bool normal_line = parse_time(l, idx_in_line_[(int) info_type.time]) && parse_date(l, idx_in_line_[(int) info_type.date]);
                if (idx_in_line_[(int) info_type.time].Item1 < 0 && idx_in_line_[(int) info_type.date].Item1 < 0)
                    // in this case, we don't have time & date - see that the level matches
                    // note: we can't rely on level too much, since the user might have additional levels that our defaults - so we could get false negatives
                    normal_line = parse_level(l, idx_in_line_[(int) info_type.level]);

                line new_ = new line(pos_in_log, l, normal_line ? idx_in_line_ : line_contains_msg_only_);
                return new_;
            } catch(Exception e) {
                logger.Error("invalid line: " + l);
                return new line(pos_in_log, l, line_contains_msg_only_);
            }
        }
Exemplo n.º 10
0
 private bool matches_case_sensitive(line l)
 {
     Debug.Assert( part != part_type.font );
     string line_part = this.line_part(l);
     return compare(line_part, text, words);
 }
Exemplo n.º 11
0
 private bool matches_case_insensitive(line l)
 {
     Debug.Assert( part != part_type.font );
     string line_part = this.line_part(l).ToLower();
     return compare(line_part, lo_text, lo_words);
 }
Exemplo n.º 12
0
        private string line_part(line l)
        {
            string sub = "";
            switch (part) {
            case part_type.date:
                sub = l.part(info_type.date);
                break;
            case part_type.time:
                sub = l.part(info_type.time);
                break;
            case part_type.level:
                sub = l.part(info_type.level);
                break;
            case part_type.message:
                sub = l.part(info_type.msg);
                break;
            case part_type.file:
                sub = l.part(info_type.file);
                break;
            case part_type.func:
                sub = l.part(info_type.func);
                break;
            case part_type.class_:
                sub = l.part(info_type.class_);
                break;

            case part_type.ctx1:
                sub = l.part(info_type.ctx1);
                break;
            case part_type.ctx2:
                sub = l.part(info_type.ctx2);
                break;
            case part_type.ctx3:
                sub = l.part(info_type.ctx3);
                break;
            case part_type.thread:
                sub = l.part(info_type.thread);
                break;

            default:
                Debug.Assert(false);
                break;
            }
            return sub;
        }
Exemplo n.º 13
0
 public bool matches(line l)
 {
     return case_sensitive ? matches_case_sensitive(l) : matches_case_insensitive(l);
 }