@@ -3696,11 +3696,11 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
36963696 if (!this ->lf_timestamp_format .empty ()) {
36973697 this ->lf_timestamp_format .push_back (nullptr );
36983698 }
3699- for ( auto iter = this -> elf_patterns . begin () ;
3700- iter != this -> elf_patterns . end () ;
3701- ++iter)
3702- {
3703- pattern& pat = *iter-> second ;
3699+ auto src_file_found = 0 ;
3700+ auto src_line_found = 0 ;
3701+ auto thread_id_found = 0 ;
3702+ for ( auto & elf_pattern : this -> elf_patterns ) {
3703+ pattern& pat = *elf_pattern. second ;
37043704
37053705 if (pat.p_pcre .pp_value == nullptr ) {
37063706 continue ;
@@ -3737,12 +3737,15 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
37373737 }
37383738 if (name == this ->elf_src_file_field ) {
37393739 pat.p_src_file_field_index = named_cap.get_index ();
3740+ src_file_found += 1 ;
37403741 }
37413742 if (name == this ->elf_src_line_field ) {
37423743 pat.p_src_line_field_index = named_cap.get_index ();
3744+ src_line_found += 1 ;
37433745 }
37443746 if (name == this ->elf_thread_id_field ) {
37453747 pat.p_thread_id_field_index = named_cap.get_index ();
3748+ thread_id_found += 1 ;
37463749 }
37473750
37483751 auto value_iter = this ->elf_value_defs .find (name);
@@ -3816,7 +3819,50 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
38163819 this ->elf_body_field .get ());
38173820 }
38183821
3819- this ->elf_pattern_order .push_back (iter->second );
3822+ this ->elf_pattern_order .push_back (elf_pattern.second );
3823+ }
3824+ if (this ->elf_type == elf_type_t ::ELF_TYPE_TEXT
3825+ && !this ->elf_src_file_field .empty () && src_file_found == 0 )
3826+ {
3827+ errors.emplace_back (
3828+ lnav::console::user_message::error (
3829+ attr_line_t (" invalid pattern: " )
3830+ .append_quoted (
3831+ lnav::roles::symbol (this ->elf_name .to_string ())))
3832+ .with_reason (" no source file capture found in the pattern" )
3833+ .with_snippets (this ->get_snippets ())
3834+ .with_help (attr_line_t (" at least one pattern needs a source "
3835+ " file capture named " )
3836+ .append_quoted (this ->elf_src_file_field .get ())));
3837+ }
3838+ if (this ->elf_type == elf_type_t ::ELF_TYPE_TEXT
3839+ && !this ->elf_src_line_field .empty () && src_line_found == 0 )
3840+ {
3841+ errors.emplace_back (
3842+ lnav::console::user_message::error (
3843+ attr_line_t (" invalid pattern: " )
3844+ .append_quoted (
3845+ lnav::roles::symbol (this ->elf_name .to_string ())))
3846+ .with_reason (" no source line capture found in the pattern" )
3847+ .with_snippets (this ->get_snippets ())
3848+ .with_help (attr_line_t (" at least one pattern needs a source "
3849+ " line capture named " )
3850+ .append_quoted (this ->elf_src_line_field .get ())));
3851+ }
3852+ if (this ->elf_type == elf_type_t ::ELF_TYPE_TEXT
3853+ && !this ->elf_thread_id_field .empty () && thread_id_found == 0 )
3854+ {
3855+ errors.emplace_back (
3856+ lnav::console::user_message::error (
3857+ attr_line_t (" invalid pattern: " )
3858+ .append_quoted (
3859+ lnav::roles::symbol (this ->elf_name .to_string ())))
3860+ .with_reason (" no thread ID capture found in the pattern" )
3861+ .with_snippets (this ->get_snippets ())
3862+ .with_help (
3863+ attr_line_t (
3864+ " at least one pattern needs a thread ID capture named " )
3865+ .append_quoted (this ->elf_thread_id_field .get ())));
38203866 }
38213867
38223868 if (this ->elf_type != elf_type_t ::ELF_TYPE_TEXT ) {
0 commit comments