|
Extracting the required text from log files
It would be highly appreciable if any one helps me in this. I am trying to get it done through Java but I love unix and believe it can be done within minutes with couple of lines.
The input log file is a text file contains multiple entries seperated by a blank line.
Each seperated entry corresponds to upgrade process information of one file.
!ENTRY text.....<INFO> or <OKAY> <RESOURCE: /test/src/com/test1/*/test.java> 2009-06-18 13:01:01.181
!MESSAGE Requesting upgrade report for file: test.java
!ENTRY text.....<INFO> or <OKAY> <RESOURCE: /test/src/com/test1/*/test1.java> 2009-06-18 13:01:01.181
!MESSAGE information in test1.java will be upgraded.
!SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: full path /file name> 2009-06-18 13:02:25.681
!MESSAGE Will add import of org.apache.beehive.netui.pageflow.annotations.Jpf for JPF annotation support.
Each Entry starts with "!ENTRY" as shown above and will be followed by text "com.bea.workshop.upgrade81 " and then it will be followed by
two types of tags: <OKAY> and <INFO>
And then it will be followed by tag <RESOURCE:which contains the full path of the file and then followed by time stamp as shown above.
If it is <OKAY>, then second line will be as below
!MESSAGE Requesting upgrade report for file: filename ( Which is not of much importance for my output)
Ex:
!ENTRY text.....<INFO> or <OKAY> <RESOURCE: /test/src/com/test1/*/test.java> 2009-06-18 13:01:01.181
!MESSAGE Requesting upgrade report for file: file name
If it is <INFO> then also second line will be like
!MESSAGE Requesting upgrade report for file: filename
But it will certainly be followed by another set of multiple line pairs starting with tags !SUBENTRY,!MESSAGE like below
!SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: path/filename> 2009-06-18 13:02:25.681
!MESSAGE Will add import of org.apache.beehive.netui.pageflow.annotations.Jpf for JPF annotation support.
My requirement is like below:
Requirement 1
1) For all entries containing <OKAY> tag, I need to extract the file names which will be after <RESOURCE:.....and before time stamp
Please note the entries are seperated by a blank line
Requirement 2
2) For all the lines with <INFO> tag, I would like to have a text file with entries like this
Full path and the file name and then in the next line
All the text after !MESAAGE right below the line containg the tag of corresponding "!SUBENTRY 1" tags
Example Input:
==============================
!ENTRY com.bea.workshop.upgrade81 <OKAY> <RESOURCE: /fullpathr/Test.java> 2009-06-18 13:02:28.368
!MESSAGE Requesting upgrade report for file: Test.java
!ENTRY com.bea.workshop.upgrade81 <OKAY> <RESOURCE: /fullpath/Test1.jpf> 2009-06-18 13:02:28.384
!MESSAGE Requesting upgrade report for file: Test1.jpf
!ENTRY com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test2.jpf> 2009-06-18 13:02:28.447
!MESSAGE Requesting upgrade report for file: Test2.jpf
!SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test2.jpf> 2009-06-18 13:02:28.447
!MESSAGE The Java 5 annotation Jpf.Controller needs to be added.
!SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test2.jpf> 2009-06-18 13:02:28.447
!MESSAGE More annotation of Jpf.Action needs to be added.
!ENTRY com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test3.jpf> 2009-06-18 13:02:28.634
!MESSAGE Requesting upgrade report for file: Test3.jpf
!SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test3.jpf> 2009-06-18 13:02:28.634
!MESSAGE The Java 5 annotation Jpf.Controller needs to be added.
!SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test3.jpf> 2009-06-18 13:02:28.634
!MESSAGE Will add import of org.apache.beehive.netui.pageflow.annotations.Jpf for JPF annotation support.
!SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test3.jpf> 2009-06-18 13:02:28.634
!MESSAGE ABC needs to be added.
Output for requirement1:
================================
Test.java
Test1.jpf
Output for requirement2:
================================
/fullpath/Test2.jpf
The Java 5 annotation Jpf.Controller needs to be added.
More annotation of Jpf.Action needs to be added.
/fullpath/Test3.jpf
The Java 5 annotation Jpf.Controller needs to be added.
Will add import of org.apache.beehive.netui.pageflow.annotations.Jpf for JPF annotation support.
ABC needs to be added.
Last edited by hareeshram; 06-20-2009 at 10:09 AM..
|