예제 #1
0
 public log_reader(log_parser parser)
 {
     Debug.Assert(parser != null);
     parser_ = parser;
     parser_.on_new_lines += on_parser_new_lines;
     logger.Info("[parse] new reader for " + parser_.name);
 }
예제 #2
0
        private void on_new_log() {
            string size = text_ is file_text_reader ? " (" + new FileInfo(text_.name).Length + " bytes)" : "";
            set_status_forever("Log: " + text_.name + size);
            dropHere.Visible = false;

            if (history_.Count < 1)
                history_select(text_.settings);

            var reader_settings_copy = new settings_as_string( text_.settings.ToString() );
            var context_settings_copy = new settings_as_string( settings_to_context(reader_settings_copy).default_settings.ToString());
            context_settings_copy.merge(reader_settings_copy.ToString());
            var file_text = text_ as file_text_reader;
            if (file_text != null) 
                if ( factory.guess_file_type(file_text.name) == "line-by-line")
                    if (reader_settings_copy.get("syntax") == "") {
                        // file reader doesn't know syntax
                        // by default - try to find the syntax by reading the header info; otherwise, try to parse it
                        string file_to_syntax = log_to.file_to_syntax(text_.name);
                        if (file_to_syntax != "") 
                            // note: file-to-syntax overrides the context syntax
                            context_settings_copy.set("syntax", file_to_syntax);                        
                        // note: if the context already knows syntax, use that
                        else if (context_settings_copy.get("syntax") == "") {
                            string found_syntax = file_text.try_to_find_log_syntax();
                            if (found_syntax != "" && found_syntax != file_text_reader.UNKNOWN_SYNTAX) 
                                context_settings_copy.set("syntax", found_syntax);
                        }
                    }            

            text_.merge_setings( context_settings_copy);

            // note: we recreate the log, so that cached filters know to rebuild
            log_parser_ = new log_parser(text_);
            log_parser_.on_aliases_changed = on_aliases_changed;
            if ( text_.settings.get("description_template") != "")
                description.set_layout( text_.settings.get("description_template"));

            ui_context log_ctx = settings_to_context( text_.settings );
            bool same_context = log_ctx == cur_context();
            if (!same_context) {
                ++ignore_change_;
                // set_aliases context based on log
                curContextCtrl.SelectedIndex = contexts_.IndexOf(log_ctx);
                --ignore_change_;

                remove_all_log_views();
                on_context_changed();
            }

            full_log_ctrl_.set_filter(new List<raw_filter_row>());
            on_new_log_parser();
            load();

            if (log_parser_.has_multi_line_columns) 
                if (!app.inst.has_shown_details_pane) {
                    app.inst.has_shown_details_pane = true;
                    show_details(global_ui.show_details = true);
                }

            add_reader_to_history();
            app.inst.set_log_file(selected_file_name());
            Text = reader_title() + " - Log Wizard " + version();

            logger.Info("new reader " + history_[logHistory.SelectedIndex].name);

            // at this point, some file has been dropped
            log_view_for_tab(0).Visible = true;

            notes.Enabled = text_ is file_text_reader;
            if (notes.Enabled) {
                notes.load(notes_keeper.inst.notes_file_for_file(text_.name));
                merge_notes();
            }

            util.postpone(update_list_view_edit, 250);
            util.postpone(check_are_settings_complete, 1500);
        }
예제 #3
0
 internal void on_set_parser(log_parser parser) {
     // call this only once!
     Debug.Assert(parser_ == null);
     parser_ = parser;                
 }
예제 #4
0
 public log_reader(log_parser parser) {
     Debug.Assert(parser != null);
     parser_ = parser;
     parser_.on_new_lines += on_parser_new_lines;
     logger.Info("[parse] new reader for " + parser_.name);
 }
예제 #5
0
 internal void on_set_parser(log_parser parser)
 {
     // call this only once!
     Debug.Assert(parser_ == null);
     parser_ = parser;
 }
예제 #6
0
 public log_reader(log_parser parser) {
     Debug.Assert(parser != null);
     parser_ = parser;
     parser_.on_new_lines += on_parser_new_lines;
 }
예제 #7
0
        private void on_new_log() {
            string size = text_ is file_text_reader ? " (" + new FileInfo(text_.name).Length + " bytes)" : "";
            set_status_forever("Log: " + text_.name + size);
            dropHere.Visible = false;

            if (history_.Count < 1)
                history_select(text_.unique_id);

            var reader_settings_copy = new settings_as_string( text_.settings.ToString() );
            var context_settings_copy = new settings_as_string( settings_to_context(reader_settings_copy).default_settings.ToString());
            context_settings_copy.merge(reader_settings_copy.ToString());
            var file_text = text_ as file_text_reader;
            if (file_text != null) 
                if ( factory.guess_file_type(file_text.name) == "line-by-line")
                    if (reader_settings_copy.get("syntax") == "") {
                        // file reader doesn't know syntax
                        // by default - try to find the syntax by reading the header info; otherwise, try to parse it
                        string file_to_syntax = log_to.file_to_syntax(text_.name);
                        if (file_to_syntax != "") {
                            // note: file-to-syntax overrides the context syntax
                            context_settings_copy.set("syntax", file_to_syntax);
                            context_settings_copy.set("syntax_type", "file_to_syntax");
                        }
                        // note: if the context already knows syntax, use that
                        else if (context_settings_copy.get("syntax") == "") {
                            string found_syntax = file_text.try_to_find_log_syntax();
                            if (found_syntax != "" && found_syntax != file_text_reader.UNKNOWN_SYNTAX) {
                                context_settings_copy.set("syntax", found_syntax);
                                context_settings_copy.set("syntax_type", "try_to_find_syntax");
                            }
                        }
                    }            

            text_.merge_setings( context_settings_copy.ToString());

            // note: we recreate the log, so that cached filters know to rebuild
            log_parser_ = new log_parser(text_);
            on_new_log_parser();

            full_log_ctrl_.set_filter(new List<raw_filter_row>());

            Text = reader_title() + " - Log Wizard " + version();
            add_reader_to_history();

            load_bookmarks();
            logger.Info("new reader " + history_[logHistory.SelectedIndex].name);

            // at this point, some file has been dropped
            log_view_for_tab(0).Visible = true;

            notes.Enabled = text_ is file_text_reader;
            if (notes.Enabled) {
                notes.load(notes_keeper.inst.notes_file_for_file(text_.name));
                merge_notes();
            }

            util.postpone(update_list_view_edit, 250);
            util.postpone(check_are_settings_complete, 1500);
        }