org.jalore.log4j
Class Log4JReader

java.lang.Object
  extended by org.jalore.log4j.Log4JReader
All Implemented Interfaces:
LogReader

public class Log4JReader
extends java.lang.Object
implements LogReader

Implementation of LogReader to read a log using a log4j pattern.

Author:
Nicolas Dutertry

Constructor Summary
Log4JReader(java.io.Reader reader, java.lang.String log4jPattern)
          Constructs a Log4JReader.
 
Method Summary
 java.util.Set<java.lang.String> getPropertyNames()
          Returns the list of property names that will be available in read log messages.
 boolean hasMoreMessages()
          Tests if this reader contains more log messages.
 LogMessage nextMessage()
          Returns the next log message of this reader or null if no more message is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4JReader

public Log4JReader(java.io.Reader reader,
                   java.lang.String log4jPattern)
            throws java.io.IOException
Constructs a Log4JReader.

The given pattern is a log4j type pattern. It must only describe the first line of log messages or the beginning of this line.

Parameters:
reader - the reader used to read the log
log4jPattern - log4j type pattern describing first line of messages
Throws:
java.io.IOException - if an error occurred while reading the log
Method Detail

hasMoreMessages

public boolean hasMoreMessages()
Description copied from interface: LogReader
Tests if this reader contains more log messages.

Specified by:
hasMoreMessages in interface LogReader
Returns:
true if and only if this reader contains at least one more log message to provide; false otherwise.

nextMessage

public LogMessage nextMessage()
                       throws java.io.IOException
Description copied from interface: LogReader
Returns the next log message of this reader or null if no more message is available.

Specified by:
nextMessage in interface LogReader
Returns:
the next log message
Throws:
java.io.IOException - if an error occurred while reading the next message

getPropertyNames

public java.util.Set<java.lang.String> getPropertyNames()
Returns the list of property names that will be available in read log messages. This list is computed from the log4j pattern used to build this log reader.

Returns:
the list of property names available in log messages


Copyright © 2009 Nicolas Dutertry. All Rights Reserved.