Class LogParser
java.lang.Object
org.apache.juneau.microservice.resources.LogParser
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<LogParser.Entry>
,Iterator<LogParser.Entry>
public final class LogParser
extends Object
implements Iterable<LogParser.Entry>, Iterator<LogParser.Entry>, Closeable
Utility class for reading log files.
Provides the capability of returning splices of log files based on dates and filtering based on thread and logger names.
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
Represents a single line from the log file. -
Constructor Summary
-
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
LogParser
public LogParser(LogEntryFormatter formatter, File f, Date start, Date end, String thread, String[] loggers, String[] severity) throws IOException Constructor.- Parameters:
formatter
- The log entry formatter.f
- The log file.start
- Don't return rows before this date. Ifnull , start from the beginning of the file.end
- Don't return rows after this date. Ifnull , go to the end of the file.thread
- Only return log entries with this thread name.loggers
- Only return log entries produced by these loggers (simple class names).severity
- Only return log entries with the specified severity.- Throws:
IOException
- Thrown by underlying stream.
-
-
Method Details
-
hasNext
- Specified by:
hasNext
in interfaceIterator<LogParser.Entry>
-
next
- Specified by:
next
in interfaceIterator<LogParser.Entry>
-
remove
- Specified by:
remove
in interfaceIterator<LogParser.Entry>
-
iterator
- Specified by:
iterator
in interfaceIterable<LogParser.Entry>
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
writeTo
Serializes the contents of the parsed log file to the specified writer and then closes the underlying reader.- Parameters:
w
- The writer to write the log file to.- Throws:
IOException
- Thrown by underlying stream.
-