@NotThreadSafe public class BuildLogFileAccessor extends Object
Modifier and Type | Method and Description |
---|---|
void |
closeFileForIteration()
close the file iterator
|
List<LogEntry> |
getLastNLogs(int numLogs)
Retrives a List of the last N logs.
|
List<LogEntry> |
getLastNLogsOfType(int numLogs,
Collection<Class<?>> types) |
int |
getNumberOfLinesInFile()
Counts the number of lines in the file.
|
int |
getNumberOfLinesOfType(Collection<Class<?>> types)
Counts the number of lines in the log file, only taking into account log entries of specified types.
|
boolean |
hasNext()
Requires file to be opened for iteration
|
@Nullable String |
nextLine()
Requires file to be opened for iteration
|
@Nullable LogEntry |
nextLogEntry()
Requires file to be opened for iteration
|
boolean |
openFileForIteration()
Open the file contained within this accessor to perform iterations (must be called before the hasNext(), nextLogEntry() and nextLine()).
|
@Nullable LogEntry |
searchFileForEntry(@Nullable String textToSearchFor,
boolean searchInErrorMessages)
Looks incrementally through the file to see if the specified text exists
|
@Nullable LogEntry |
searchFileForEntry(@Nullable String textToSearchFor,
int lastNLines,
boolean searchInErrorMessages)
Searchers for particular text within the last n lines of a file (eg search within the last 10 lines for a success message)
|
public static final String ENCODING
public boolean openFileForIteration()
public void closeFileForIteration()
public boolean hasNext()
@Nullable public @Nullable LogEntry nextLogEntry()
@Nullable public @Nullable String nextLine()
@Nullable public @Nullable LogEntry searchFileForEntry(@Nullable @Nullable String textToSearchFor, boolean searchInErrorMessages) throws IOException
textToSearchFor
- the specific text to search forsearchInErrorMessages
- search also in error messagesIOException
- if there were errors accessing the file@Nullable public @Nullable LogEntry searchFileForEntry(@Nullable @Nullable String textToSearchFor, int lastNLines, boolean searchInErrorMessages) throws IOException
textToSearchFor
- String text to find in filelastNLines
- number of lines from end to search fromsearchInErrorMessages
- search also in error messagesIOException
- if error closing the log filepublic List<LogEntry> getLastNLogs(int numLogs) throws IOException
numLogs
- number of logs to retrieveIOException
- if errors access the build log filepublic List<LogEntry> getLastNLogsOfType(int numLogs, Collection<Class<?>> types) throws IOException
IOException
public int getNumberOfLinesInFile() throws IOException
IOException
- if errors accessing the filepublic int getNumberOfLinesOfType(Collection<Class<?>> types) throws IOException
SimpleLogEntry
will
also include log count for types CommandLogEntry
or ErrorLogEntry
)types
- types of log entries for which to calculate resultIOException
- if errors occur while accessing the log fileCopyright © 2022 Atlassian Software Systems Pty Ltd. All rights reserved.