Interface LogParser

  • All Implemented Interfaces:

    
    public interface LogParser
    
                        

    Description: LogParser is the base interface for classes implementing concrete parse logic. For an example of how to use the interface, look at the Tomcat access log parser.

    The original log parser was written in 2 hours to parse access logs. Since then, the design and implementation has been rewritten from scratch several times to make it more generic and extensible. The first version was hard coded and written over the weekend.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract void close() close the any streams or readers.
      abstract int parseAndConfigure(int count, TestElement el) the method will parse the given number of lines.
      abstract void setFilter(Filter filter) We allow for filters, so that users can simply point to an Access log without having to clean it up.
      abstract void setSourceFile(String source) The method is provided to make it easy to dynamically create new classes using Class.newInstance().
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • close

         abstract void close()

        close the any streams or readers.

      • parseAndConfigure

         abstract int parseAndConfigure(int count, TestElement el)

        the method will parse the given number of lines. Pass "-1" to parse the entire file. If the end of the file is reached without parsing a line, a 0 is returned. If the method is subsequently called again, it will restart parsing at the beginning.

        Parameters:
        count - max lines to parse, or -1 for the entire file
        el - TestElement to read lines into
        Returns:

        number of lines parsed

      • setFilter

         abstract void setFilter(Filter filter)

        We allow for filters, so that users can simply point to an Access log without having to clean it up. This makes it significantly easier and reduces the amount of work. Plus I'm lazy, so going through a log file to clean it up is a bit tedious. One example of this is using the filter to exclude any log entry that has a 505 response code.

        Parameters:
        filter - Filter to use
      • setSourceFile

         abstract void setSourceFile(String source)

        The method is provided to make it easy to dynamically create new classes using Class.newInstance(). Then the access log file is set using this method.

        Parameters:
        source - name of the access log file