/// <summary>
        /// Checks if the file name is a settings file. If so, the contained logfile name
        /// is returned. If not, the given file name is returned unchanged.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private string FindFilenameForSettings(string fileName)
        {
            if (fileName.EndsWith(".lxp"))
            {
                PersistenceData persistenceData = Persister.LoadOptionsOnly(fileName);
                if (persistenceData == null)
                {
                    return(fileName);
                }

                if (persistenceData.fileName != null && persistenceData.fileName.Length > 0)
                {
                    IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(persistenceData.fileName);
                    if (fs != null && !fs.GetType().Equals(typeof(LocalFileSystem)))
                    {
                        return(persistenceData.fileName);
                    }

                    // On relative paths the URI check (and therefore the file system plugin check) will fail.
                    // So fs == null and fs == LocalFileSystem are handled here like normal files.
                    if (Path.IsPathRooted(persistenceData.fileName))
                    {
                        return(persistenceData.fileName);
                    }
                    else
                    {
                        // handle relative paths in .lxp files
                        string dir = Path.GetDirectoryName(fileName);
                        return(Path.Combine(dir, persistenceData.fileName));
                    }
                }
            }

            return(fileName);
        }
        private bool FileExists(string filePath)
        {
            IFileSystemPlugin fs   = PluginRegistry.GetInstance().FindFileSystemForUri(filePath);
            ILogFileInfo      info = fs.GetLogfileInfo(filePath);

            return(info.FileExists);
        }
Beispiel #3
0
        public ILogLineColumnizer FindColumnizer(string fileName, LogfileReader logFileReader)
        {
            if (logFileReader == null || string.IsNullOrEmpty(fileName))
            {
                return(new DefaultLogfileColumnizer());
            }

            ILogLineColumnizer lineColumnizer = null;
            var             timeDeterminer    = new TimeFormatDeterminer();
            List <ILogLine> loglines          = new List <ILogLine>
            {
                // Sampling a few lines to select the correct columnizer
                logFileReader.GetLogLine(0),
                logFileReader.GetLogLine(1),
                logFileReader.GetLogLine(2),
                logFileReader.GetLogLine(3),
                logFileReader.GetLogLine(4),
                logFileReader.GetLogLine(5),
                logFileReader.GetLogLine(25),
                logFileReader.GetLogLine(100),
                logFileReader.GetLogLine(200),
                logFileReader.GetLogLine(400)
            };

            lineColumnizer = PluginRegistry.GetInstance().RegisteredColumnizers.OrderByDescending(x => x.GetPriority(fileName, loglines)).First();

            return(lineColumnizer);
        }
Beispiel #4
0
 public static PluginRegistry GetInstance()
 {
     lock (lockObject)
     {
         if (instance == null)
         {
             instance = new PluginRegistry();
         }
         return(instance);
     }
 }
        public ILogLineColumnizer GetColumnizerHistoryEntry(string fileName)
        {
            ColumnizerHistoryEntry entry = findColumnizerHistoryEntry(fileName);

            if (entry != null)
            {
                foreach (ILogLineColumnizer columnizer in PluginRegistry.GetInstance().RegisteredColumnizers)
                {
                    if (columnizer.GetName().Equals(entry.columnizerName))
                    {
                        return(columnizer);
                    }
                }
                ConfigManager.Settings.columnizerHistoryList.Remove(entry); // no valid name -> remove entry
            }
            return(null);
        }
 public void WindowClosed(LogTabWindow logWin)
 {
     RemoveWindow(logWin);
     if (this.windowList.Count == 0)
     {
         _logger.Info("Last LogTabWindow was closed");
         PluginRegistry.GetInstance().CleanupPlugins();
         OnLastWindowClosed();
     }
     else
     {
         if (this.firstLogTabWindow == logWin)
         {
             // valid firstLogTabWindow is needed for the Invoke()-Calls in NewWindow()
             this.firstLogTabWindow = this.windowList[this.windowList.Count - 1];
         }
     }
 }
        private void ShowHighlightSettingsDialog()
        {
            HilightDialog dlg = new HilightDialog();

            dlg.KeywordActionList    = PluginRegistry.GetInstance().RegisteredKeywordActions;
            dlg.Owner                = this;
            dlg.TopMost              = TopMost;
            dlg.HilightGroupList     = HilightGroupList;
            dlg.PreSelectedGroupName = highlightGroupsComboBox.Text;
            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                HilightGroupList = dlg.HilightGroupList;
                FillHighlightComboBox();
                ConfigManager.Settings.hilightGroupList = HilightGroupList;
                ConfigManager.Save(SettingsFlags.HighlightSettings);
                OnHighlightSettingsChanged();
            }
        }
Beispiel #8
0
        public LogWindow(LogTabWindow parent, string fileName, bool isTempFile,
                         bool forcePersistenceLoading)
        {
            SuspendLayout();

            InitializeComponent();

            columnNamesLabel.Text = ""; // no filtering on columns by default

            parentLogTabWin = parent;
            IsTempFile      = isTempFile;
            //Thread.CurrentThread.Name = "LogWindowThread";
            ColumnizerCallbackObject = new ColumnizerCallback(this);

            FileName = fileName;
            ForcePersistenceLoading = forcePersistenceLoading;

            dataGridView.CellValueNeeded += dataGridView_CellValueNeeded;
            dataGridView.CellPainting    += dataGridView_CellPainting;

            filterGridView.CellValueNeeded += filterGridView_CellValueNeeded;
            filterGridView.CellPainting    += filterGridView_CellPainting;

            Closing  += LogWindow_Closing;
            Disposed += LogWindow_Disposed;

            timeSpreadCalc = new TimeSpreadCalculator(this);
            timeSpreadingControl1.TimeSpreadCalc       = timeSpreadCalc;
            timeSpreadingControl1.LineSelected        += timeSpreadingControl1_LineSelected;
            tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute;
            tableLayoutPanel1.ColumnStyles[1].Width    = 20;
            tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent;
            tableLayoutPanel1.ColumnStyles[0].Width    = 100;

            parentLogTabWin.HighlightSettingsChanged += parent_HighlightSettingsChanged;

            SetColumnizer(PluginRegistry.GetInstance().RegisteredColumnizers[0]);

            patternArgs.maxMisses      = 5;
            patternArgs.minWeight      = 1;
            patternArgs.maxDiffInBlock = 5;
            patternArgs.fuzzy          = 5;

            //InitPatternWindow();

            //this.toolwinTabControl.TabPages.Add(this.patternWindow);
            //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow);

            filterParams = new FilterParams();
            foreach (string item in ConfigManager.Settings.filterHistoryList)
            {
                filterComboBox.Items.Add(item);
            }

            filterComboBox.DropDownHeight = filterComboBox.ItemHeight * ConfigManager.Settings.preferences.maximumFilterEntriesDisplayed;

            filterRegexCheckBox.Checked         = filterParams.isRegex;
            filterCaseSensitiveCheckBox.Checked = filterParams.isCaseSensitive;
            filterTailCheckBox.Checked          = filterParams.isFilterTail;

            splitContainer1.Panel2Collapsed = true;
            advancedFilterSplitContainer.SplitterDistance = FILTER_ADCANCED_SPLITTER_DISTANCE;

            timeshiftSyncThread = new Thread(SyncTimestampDisplayWorker);
            timeshiftSyncThread.IsBackground = true;
            timeshiftSyncThread.Start();

            logEventHandlerThread = new Thread(LogEventWorker);
            logEventHandlerThread.IsBackground = true;
            logEventHandlerThread.Start();

            //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker));
            //this.filterUpdateThread.Start();

            advancedButtonImage      = advancedButton.Image;
            searchButtonImage        = filterSearchButton.Image;
            filterSearchButton.Image = null;

            dataGridView.EditModeMenuStrip        = editModeContextMenuStrip;
            markEditModeToolStripMenuItem.Enabled = true;

            panelOpenButtonImage  = new Bitmap(GetType(), "Resources.PanelOpen.gif");
            panelCloseButtonImage = new Bitmap(GetType(), "Resources.PanelClose.gif");

            Settings settings = ConfigManager.Settings;

            if (settings.appBounds != null && settings.appBounds.Right > 0)
            {
                Bounds = settings.appBounds;
            }

            waitingForClose      = false;
            dataGridView.Enabled = false;
            dataGridView.ColumnDividerDoubleClick += dataGridView_ColumnDividerDoubleClick;
            ShowAdvancedFilterPanel(false);
            filterKnobControl1.MinValue      = 0;
            filterKnobControl1.MaxValue      = SPREAD_MAX;
            filterKnobControl1.ValueChanged += filterKnobControl1_ValueChanged;
            filterKnobControl2.MinValue      = 0;
            filterKnobControl2.MaxValue      = SPREAD_MAX;
            filterKnobControl2.ValueChanged += filterKnobControl1_ValueChanged;
            fuzzyKnobControl.MinValue        = 0;
            fuzzyKnobControl.MaxValue        = 10;
            //PreferencesChanged(settings.preferences, true);
            AdjustHighlightSplitterWidth();
            ToggleHighlightPanel(false); // hidden

            bookmarkProvider.BookmarkAdded       += bookmarkProvider_BookmarkAdded;
            bookmarkProvider.BookmarkRemoved     += bookmarkProvider_BookmarkRemoved;
            bookmarkProvider.AllBookmarksRemoved += bookmarkProvider_AllBookmarksRemoved;

            ResumeLayout();

            statusLineTrigger.Signal       += statusLineTrigger_Signal;
            selectionChangedTrigger.Signal += selectionChangedTrigger_Signal;

            PreferencesChanged(parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors);
        }
        private void StartTool(string cmd, string args, bool sysoutPipe, string columnizerName, string workingDir)
        {
            if (string.IsNullOrEmpty(cmd))
            {
                return;
            }

            Process          process   = new Process();
            ProcessStartInfo startInfo = new ProcessStartInfo(cmd, args);

            if (!Util.IsNull(workingDir))
            {
                startInfo.WorkingDirectory = workingDir;
            }

            process.StartInfo           = startInfo;
            process.EnableRaisingEvents = true;

            if (sysoutPipe)
            {
                ILogLineColumnizer columnizer = Util.FindColumnizerByName(columnizerName,
                                                                          PluginRegistry.GetInstance().RegisteredColumnizers);
                if (columnizer == null)
                {
                    columnizer = PluginRegistry.GetInstance().RegisteredColumnizers[0];
                }

                _logger.Info("Starting external tool with sysout redirection: {0} {1}", cmd, args);
                startInfo.UseShellExecute        = false;
                startInfo.RedirectStandardOutput = true;
                //process.OutputDataReceived += pipe.DataReceivedEventHandler;
                try
                {
                    process.Start();
                }
                catch (Win32Exception e)
                {
                    _logger.Error(e);
                    MessageBox.Show(e.Message);
                    return;
                }

                SysoutPipe pipe   = new SysoutPipe(process.StandardOutput);
                LogWindow  logWin = AddTempFileTab(pipe.FileName,
                                                   CurrentLogWindow.IsTempFile
                        ? CurrentLogWindow.TempTitleName
                        : Util.GetNameFromPath(CurrentLogWindow.FileName) + "->E");
                logWin.ForceColumnizer(columnizer);
                process.Exited += pipe.ProcessExitedEventHandler;
                //process.BeginOutputReadLine();
            }
            else
            {
                _logger.Info("Starting external tool: {0} {1}", cmd, args);
                try
                {
                    startInfo.UseShellExecute = false;
                    process.Start();
                }
                catch (Exception e)
                {
                    _logger.Error(e);
                    MessageBox.Show(e.Message);
                }
            }
        }
Beispiel #10
0
        private void selectFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CurrentLogWindow == null)
            {
                return;
            }
            CurrentLogWindow.ColumnizerCallbackObject.LineNum = CurrentLogWindow.GetCurrentLineNum();
            FilterSelectorForm form = new FilterSelectorForm(PluginRegistry.GetInstance().RegisteredColumnizers,
                                                             CurrentLogWindow.CurrentColumnizer,
                                                             CurrentLogWindow.ColumnizerCallbackObject);

            form.Owner   = this;
            form.TopMost = TopMost;
            DialogResult res = form.ShowDialog();

            if (res == DialogResult.OK)
            {
                if (form.ApplyToAll)
                {
                    lock (logWindowList)
                    {
                        foreach (LogWindow logWindow in logWindowList)
                        {
                            if (!logWindow.CurrentColumnizer.GetType().Equals(form.SelectedColumnizer.GetType()))
                            {
                                //logWindow.SetColumnizer(form.SelectedColumnizer);
                                SetColumnizerFx fx = logWindow.ForceColumnizer;
                                logWindow.Invoke(fx, form.SelectedColumnizer);
                                setColumnizerHistoryEntry(logWindow.FileName, form.SelectedColumnizer);
                            }
                            else
                            {
                                if (form.IsConfigPressed)
                                {
                                    logWindow.ColumnizerConfigChanged();
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (!CurrentLogWindow.CurrentColumnizer.GetType().Equals(form.SelectedColumnizer.GetType()))
                    {
                        SetColumnizerFx fx = CurrentLogWindow.ForceColumnizer;
                        CurrentLogWindow.Invoke(fx, form.SelectedColumnizer);
                        setColumnizerHistoryEntry(CurrentLogWindow.FileName, form.SelectedColumnizer);
                    }
                    if (form.IsConfigPressed)
                    {
                        lock (logWindowList)
                        {
                            foreach (LogWindow logWindow in logWindowList)
                            {
                                if (logWindow.CurrentColumnizer.GetType().Equals(form.SelectedColumnizer.GetType()))
                                {
                                    logWindow.ColumnizerConfigChanged();
                                }
                            }
                        }
                    }
                }
            }
        }
 public ILogLineColumnizer FindColumnizerByFileMask(string fileName)
 {
     foreach (ColumnizerMaskEntry entry in ConfigManager.Settings.preferences.columnizerMaskList)
     {
         if (entry.mask != null)
         {
             try
             {
                 if (Regex.IsMatch(fileName, entry.mask))
                 {
                     ILogLineColumnizer columnizer = Util.FindColumnizerByName(entry.columnizerName,
                                                                               PluginRegistry.GetInstance().RegisteredColumnizers);
                     return(columnizer);
                 }
             }
             catch (ArgumentException e)
             {
                 _logger.Error(e, "RegEx-error while finding columnizer: ");
                 // occurs on invalid regex patterns
             }
         }
     }
     return(null);
 }