|
3 | 3 |
|
4 | 4 | namespace LogExpert.Core.Interface; |
5 | 5 |
|
6 | | -//TODO: Add documentation |
| 6 | +/// <summary> |
| 7 | +/// Represents a log window that displays and manages a log file in LogExpert. |
| 8 | +/// This interface provides access to log file content, timestamp operations, line selection, |
| 9 | +/// and persistence functionality. |
| 10 | +/// </summary> |
| 11 | +/// <remarks> |
| 12 | +/// This interface is primarily implemented by the LogWindow class in LogExpert.UI. |
| 13 | +/// It serves as an abstraction layer between the core functionality and the UI layer, |
| 14 | +/// allowing for loose coupling between components. |
| 15 | +/// </remarks> |
7 | 16 | public interface ILogWindow |
8 | 17 | { |
| 18 | + /// <summary> |
| 19 | + /// Gets the file name of the log file that contains the specified line number. |
| 20 | + /// </summary> |
| 21 | + /// <param name="lineNum">The zero-based line number.</param> |
| 22 | + /// <returns>The file name (without path) of the log file containing the specified line. |
| 23 | + /// In multi-file mode, this may return different file names for different line numbers.</returns> |
| 24 | + /// <remarks> |
| 25 | + /// This method is particularly useful in multi-file mode where multiple log files |
| 26 | + /// are viewed together as one virtual file. |
| 27 | + /// </remarks> |
9 | 28 | string GetCurrentFileName (int lineNum); |
10 | 29 |
|
| 30 | + /// <summary> |
| 31 | + /// Gets the log line at the specified line number. |
| 32 | + /// </summary> |
| 33 | + /// <param name="lineNum">The zero-based line number to retrieve.</param> |
| 34 | + /// <returns> |
| 35 | + /// An <see cref="ILogLine"/> object containing the line content and metadata, |
| 36 | + /// or <c>null</c> if the line number is out of range or the line cannot be retrieved. |
| 37 | + /// </returns> |
| 38 | + /// <remarks> |
| 39 | + /// This method retrieves lines from the internal buffer cache and may trigger |
| 40 | + /// disk reads if the line is not currently cached. |
| 41 | + /// </remarks> |
11 | 42 | ILogLine GetLine (int lineNum); |
12 | 43 |
|
| 44 | + /// <summary> |
| 45 | + /// Gets the log line at the specified line number asynchronously, with a timeout. |
| 46 | + /// </summary> |
| 47 | + /// <param name="lineNum">The zero-based line number to retrieve.</param> |
| 48 | + /// <returns> |
| 49 | + /// An <see cref="ILogLine"/> object containing the line content and metadata, |
| 50 | + /// or <c>null</c> if the operation times out or the line cannot be retrieved. |
| 51 | + /// </returns> |
| 52 | + /// <remarks> |
| 53 | + /// <para> |
| 54 | + /// This method waits for up to 1 second for the line to be loaded. If the line |
| 55 | + /// is not available within that time, it returns <c>null</c>. This prevents |
| 56 | + /// the GUI thread from freezing when files are slow to load (e.g., from network shares |
| 57 | + /// or when files have been deleted). |
| 58 | + /// </para> |
| 59 | + /// <para> |
| 60 | + /// After detecting a timeout, the method enters a 'fast fail mode' where subsequent |
| 61 | + /// calls return <c>null</c> immediately. A background operation checks if the issue |
| 62 | + /// is resolved and exits fast fail mode when the file becomes accessible again. |
| 63 | + /// </para> |
| 64 | + /// </remarks> |
13 | 65 | ILogLine GetLogLineWithWait (int lineNum); |
14 | 66 |
|
| 67 | + /// <summary> |
| 68 | + /// Gets the timestamp for the line at or after the specified line number, |
| 69 | + /// searching forward through the file. |
| 70 | + /// </summary> |
| 71 | + /// <param name="lineNum"> |
| 72 | + /// A reference to the line number to start searching from. |
| 73 | + /// This value is updated to the line number where the timestamp was found. |
| 74 | + /// </param> |
| 75 | + /// <param name="roundToSeconds"> |
| 76 | + /// If <c>true</c>, the returned timestamp is rounded to the nearest second. |
| 77 | + /// </param> |
| 78 | + /// <returns> |
| 79 | + /// The timestamp of the line at or after the specified line number, |
| 80 | + /// or <see cref="DateTime.MinValue"/> if no valid timestamp is found. |
| 81 | + /// </returns> |
| 82 | + /// <remarks> |
| 83 | + /// Not all log lines may contain timestamps. This method searches forward |
| 84 | + /// from the given line number until it finds a line with a valid timestamp. |
| 85 | + /// The <paramref name="lineNum"/> parameter is updated to reflect the line |
| 86 | + /// where the timestamp was found. |
| 87 | + /// </remarks> |
15 | 88 | //TODO Find a way to not use a referenced int (https://github.com/LogExperts/LogExpert/issues/404) |
16 | 89 | DateTime GetTimestampForLineForward (ref int lineNum, bool roundToSeconds); |
17 | 90 |
|
| 91 | + /// <summary> |
| 92 | + /// Gets the timestamp for the line at or before the specified line number, |
| 93 | + /// searching backward through the file. |
| 94 | + /// </summary> |
| 95 | + /// <param name="lastLineNum"> |
| 96 | + /// A reference to the line number to start searching from. |
| 97 | + /// This value is updated to the line number where the timestamp was found. |
| 98 | + /// </param> |
| 99 | + /// <param name="roundToSeconds"> |
| 100 | + /// If <c>true</c>, the returned timestamp is rounded to the nearest second. |
| 101 | + /// </param> |
| 102 | + /// <returns> |
| 103 | + /// The timestamp of the line at or before the specified line number, |
| 104 | + /// or <see cref="DateTime.MinValue"/> if no valid timestamp is found. |
| 105 | + /// </returns> |
| 106 | + /// <remarks> |
| 107 | + /// Not all log lines may contain timestamps. This method searches backward |
| 108 | + /// from the given line number until it finds a line with a valid timestamp. |
| 109 | + /// The <paramref name="lastLineNum"/> parameter is updated to reflect the line |
| 110 | + /// where the timestamp was found. |
| 111 | + /// </remarks> |
18 | 112 | //TODO Find a way to not use a referenced int (https://github.com/LogExperts/LogExpert/issues/404) |
19 | 113 | DateTime GetTimestampForLine (ref int lastLineNum, bool roundToSeconds); |
20 | 114 |
|
| 115 | + /// <summary> |
| 116 | + /// Finds the line number that corresponds to the specified timestamp within |
| 117 | + /// the given range, using a binary search algorithm. |
| 118 | + /// </summary> |
| 119 | + /// <param name="lineNum">The starting line number for the search.</param> |
| 120 | + /// <param name="rangeStart">The first line number of the search range (inclusive).</param> |
| 121 | + /// <param name="rangeEnd">The last line number of the search range (inclusive).</param> |
| 122 | + /// <param name="timestamp">The timestamp to search for.</param> |
| 123 | + /// <param name="roundToSeconds"> |
| 124 | + /// If <c>true</c>, timestamps are rounded to seconds for comparison. |
| 125 | + /// </param> |
| 126 | + /// <returns> |
| 127 | + /// The line number of the line with a timestamp closest to the specified timestamp, |
| 128 | + /// or -1 if no matching line is found within the range. |
| 129 | + /// </returns> |
| 130 | + /// <remarks> |
| 131 | + /// This method is used for timestamp-based navigation and synchronization between |
| 132 | + /// multiple log windows. It performs a binary search for optimal performance. |
| 133 | + /// </remarks> |
21 | 134 | int FindTimestampLineInternal (int lineNum, int rangeStart, int rangeEnd, DateTime timestamp, bool roundToSeconds); |
22 | 135 |
|
| 136 | + /// <summary> |
| 137 | + /// Selects the specified line in the log view and optionally scrolls to make it visible. |
| 138 | + /// </summary> |
| 139 | + /// <param name="lineNum">The zero-based line number to select.</param> |
| 140 | + /// <param name="triggerSyncCall"> |
| 141 | + /// If <c>true</c>, triggers timestamp synchronization with other log windows |
| 142 | + /// that are in sync mode. |
| 143 | + /// </param> |
| 144 | + /// <param name="shouldScroll"> |
| 145 | + /// If <c>true</c>, scrolls the view to ensure the selected line is visible. |
| 146 | + /// </param> |
| 147 | + /// <remarks> |
| 148 | + /// This method is used for programmatic line selection, such as when jumping |
| 149 | + /// to bookmarks, navigating through search results, or synchronizing with other windows. |
| 150 | + /// </remarks> |
23 | 151 | void SelectLine (int lineNum, bool triggerSyncCall, bool shouldScroll); |
24 | 152 |
|
| 153 | + /// <summary> |
| 154 | + /// Gets the persistence data for this log window, which can be saved and later restored. |
| 155 | + /// </summary> |
| 156 | + /// <returns> |
| 157 | + /// A <see cref="PersistenceData"/> object containing the current state of the window, |
| 158 | + /// including the current line, filters, columnizer configuration, and other settings. |
| 159 | + /// </returns> |
| 160 | + /// <remarks> |
| 161 | + /// This data is used to restore the log window state between sessions, including |
| 162 | + /// the current scroll position, active filters, and columnizer settings. |
| 163 | + /// </remarks> |
25 | 164 | PersistenceData GetPersistenceData (); |
26 | 165 |
|
| 166 | + /// <summary> |
| 167 | + /// Creates a new temporary file tab with the specified content. |
| 168 | + /// </summary> |
| 169 | + /// <param name="fileName">The path to the temporary file to display.</param> |
| 170 | + /// <param name="title">The title to display on the tab.</param> |
| 171 | + /// <remarks> |
| 172 | + /// Temporary file tabs are used for displaying filtered content, search results, |
| 173 | + /// or other derived views of the original log file. |
| 174 | + /// </remarks> |
27 | 175 | void AddTempFileTab (string fileName, string title); |
28 | 176 |
|
| 177 | + /// <summary> |
| 178 | + /// Creates a new tab containing the specified list of log line entries. |
| 179 | + /// </summary> |
| 180 | + /// <param name="lineEntryList"> |
| 181 | + /// A list of <see cref="LineEntry"/> objects containing the lines and their |
| 182 | + /// original line numbers to display in the new tab. |
| 183 | + /// </param> |
| 184 | + /// <param name="title">The title to display on the tab.</param> |
| 185 | + /// <remarks> |
| 186 | + /// This method is used to pipe filtered or selected content into a new tab |
| 187 | + /// without creating a physical file. The new tab maintains references to the |
| 188 | + /// original line numbers for context. |
| 189 | + /// </remarks> |
29 | 190 | void WritePipeTab (IList<LineEntry> lineEntryList, string title); |
30 | 191 |
|
| 192 | + /// <summary> |
| 193 | + /// Activates this log window and brings it to the foreground. |
| 194 | + /// </summary> |
| 195 | + /// <remarks> |
| 196 | + /// This method is typically called when switching between multiple log windows |
| 197 | + /// or when a background operation completes and needs to notify the user. |
| 198 | + /// </remarks> |
31 | 199 | void Activate (); |
32 | 200 |
|
| 201 | + /// <summary> |
| 202 | + /// Gets the <see cref="LogfileReader"/> instance that provides access to the |
| 203 | + /// underlying log file content. |
| 204 | + /// </summary> |
| 205 | + /// <value> |
| 206 | + /// The <see cref="LogfileReader"/> that manages file access, buffering, and |
| 207 | + /// multi-file coordination for this log window. |
| 208 | + /// </value> |
| 209 | + /// <remarks> |
| 210 | + /// The LogfileReader handles all file I/O operations, including reading lines, |
| 211 | + /// monitoring for file changes, and managing the buffer cache. |
| 212 | + /// </remarks> |
33 | 213 | LogfileReader LogFileReader { get; } |
34 | 214 |
|
| 215 | + /// <summary> |
| 216 | + /// Gets the text content of the currently selected cell or line. |
| 217 | + /// </summary> |
| 218 | + /// <value> |
| 219 | + /// The text content of the current selection, or an empty string if nothing is selected. |
| 220 | + /// </value> |
35 | 221 | string Text { get; } |
36 | 222 |
|
| 223 | + /// <summary> |
| 224 | + /// Gets the file name (with full path) of the primary log file being displayed. |
| 225 | + /// </summary> |
| 226 | + /// <value> |
| 227 | + /// The full file path of the log file, or an empty string if no file is loaded. |
| 228 | + /// </value> |
| 229 | + /// <remarks> |
| 230 | + /// In multi-file mode, this returns the path of the first file in the multi-file set. |
| 231 | + /// Use <see cref="GetCurrentFileName"/> to get the file name for a specific line number. |
| 232 | + /// </remarks> |
37 | 233 | string FileName { get; } |
38 | 234 |
|
39 | 235 | //event EventHandler<LogEventArgs> FileSizeChanged; //TODO: All handlers should be moved to Core |
|
0 commit comments