Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 203622 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/hyades/logging/parsers/AbstractErrorLogParser.java (-34 / +61 lines)
Lines 27-32 Link Here
27
import java.util.Date;
27
import java.util.Date;
28
import java.util.Hashtable;
28
import java.util.Hashtable;
29
import java.util.Locale;
29
import java.util.Locale;
30
import java.util.TimeZone;
30
31
31
import org.eclipse.hyades.logging.adapter.AdapterException;
32
import org.eclipse.hyades.logging.adapter.AdapterException;
32
import org.eclipse.hyades.logging.core.Guid;
33
import org.eclipse.hyades.logging.core.Guid;
Lines 43-48 Link Here
43
import org.eclipse.hyades.logging.events.cbe.util.EventHelpers;
44
import org.eclipse.hyades.logging.events.cbe.util.EventHelpers;
44
import org.eclipse.hyades.logging.parsers.util.FilterExitHelper;
45
import org.eclipse.hyades.logging.parsers.util.FilterExitHelper;
45
46
47
46
/** 
48
/** 
47
 * <code>AbstractErrorLogParser</code> is the abstract superclass for the <code>ApacheErrorLogParser</code>.
49
 * <code>AbstractErrorLogParser</code> is the abstract superclass for the <code>ApacheErrorLogParser</code>.
48
 * <p>
50
 * <p>
Lines 115-121 Link Here
115
    protected String sourceID = null;
117
    protected String sourceID = null;
116
118
117
    //Private variables:
119
    //Private variables:
118
    
120
    /**
121
	 * Variable to hold the tempTimezone value
122
	 */
123
	private TimeZone timeZone = null;
119
    /**
124
    /**
120
     * bugzilla 139164
125
     * bugzilla 139164
121
     * Count of records with identical time stamp values. 
126
     * Count of records with identical time stamp values. 
Lines 150-157 Link Here
150
    public void setConfiguration(Hashtable table) throws LogParserException {
155
    public void setConfiguration(Hashtable table) throws LogParserException {
151
    	super.setConfiguration(table);
156
    	super.setConfiguration(table);
152
    	sensorFilterExitHelper.init(table , filterExitClassInstance) ;
157
    	sensorFilterExitHelper.init(table , filterExitClassInstance) ;
158
    	String timezone = (String)table.get("timezone");
159
        inittimezone(timezone);
153
    }
160
    }
154
    
161
	/*
162
	 * Intialize the timezone value to the system default timezone value 
163
	 */
164
	  private void inittimezone(String timezone)
165
	  {
166
	  	if(timezone == null || timezone.equals("") ||timezone.equals("default")||timezone.equals("Default"))
167
	  	{
168
	  		timeZone = TimeZone.getDefault();
169
	  	}
170
	  	else
171
	  	{
172
	  		StringBuffer tempTimezone = new StringBuffer(timezone);
173
	  		tempTimezone.insert(3, ':');
174
	  		timezone = tempTimezone.toString();
175
	  		timeZone = TimeZone.getTimeZone("GMT"+timezone);
176
	  	}
177
	  }
178
 
179
	  public String getLogTimezone(Date creationDate) 
180
	  {
181
		//Generate the local UTC offset using the parsed date:
182
		  StringBuffer timezoneStr = new StringBuffer();
183
          Calendar localCalendar = Calendar.getInstance();
184
          localCalendar.setTimeZone(timeZone);
185
          localCalendar.setTime(creationDate);
186
          int utcOffset = ((localCalendar.get(Calendar.ZONE_OFFSET) + localCalendar.get(Calendar.DST_OFFSET)) / 60000);
187
          //Add the sign of the UTC offset:
188
          if (utcOffset < 0)
189
        	  timezoneStr.append("-");
190
          else
191
        	  timezoneStr.append("+");
192
193
          utcOffset = Math.abs(utcOffset);
194
          // Time Zone (+/-hh:mm)
195
196
          String numberHours = String.valueOf(utcOffset / 60);
197
198
          if (numberHours.length() == 1)
199
        	  timezoneStr.append("0");
200
201
          timezoneStr.append(numberHours);
202
          timezoneStr.append(":");
203
204
          String numberMinutes = String.valueOf(utcOffset % 60);
205
206
          if (numberMinutes.length() == 1)
207
        	  timezoneStr.append("0");
208
          timezoneStr.append(numberMinutes);
209
          
210
          return timezoneStr.toString();
211
	  }
155
    /**
212
    /**
156
     * Initialize this parser.
213
     * Initialize this parser.
157
     * @throws LogParserException if the parser cannot be initialized.
214
     * @throws LogParserException if the parser cannot be initialized.
Lines 542-548 Link Here
542
            //Parse the access log's time stamp excluding the time zone offset and square brackets (e.g. Thu Jan 16 19:06:54 2002) to a java.util.Date object:
599
            //Parse the access log's time stamp excluding the time zone offset and square brackets (e.g. Thu Jan 16 19:06:54 2002) to a java.util.Date object:
543
        	// bugzilla 152372 - use the parser class SimpleDateFormat instance variable SDFparser for parsing the time stamp 
600
        	// bugzilla 152372 - use the parser class SimpleDateFormat instance variable SDFparser for parsing the time stamp 
544
            Date creationDate = SDFparser.parse(curLine.substring((startIndex + 1), endIndex).trim(), new ParsePosition(0));
601
            Date creationDate = SDFparser.parse(curLine.substring((startIndex + 1), endIndex).trim(), new ParsePosition(0));
545
602
           
546
            //If the access log's time stamp is valid (e.g. non-null java.util.Date object), convert to its XML dateTime format:
603
            //If the access log's time stamp is valid (e.g. non-null java.util.Date object), convert to its XML dateTime format:
547
            if (creationDate != null) {
604
            if (creationDate != null) {
548
605
Lines 555-591 Link Here
555
612
556
                //Add the fractional second value (e.g. .000000):
613
                //Add the fractional second value (e.g. .000000):
557
                currentTimeStamp.append(ParserConstants.SIX_ZERO);
614
                currentTimeStamp.append(ParserConstants.SIX_ZERO);
558
615
                currentTimeStamp.append(getLogTimezone(creationDate));
559
                //Generate the local UTC offset using the parsed date:
560
                Calendar localCalendar = Calendar.getInstance();
561
                localCalendar.setTime(creationDate);
562
                int utcOffset = ((localCalendar.get(Calendar.ZONE_OFFSET) + localCalendar.get(Calendar.DST_OFFSET)) / 60000);
563
564
                //Add the sign of the UTC offset:
565
                if (utcOffset < 0)
566
                    currentTimeStamp.append("-");
567
                else
568
                    currentTimeStamp.append("+");
569
570
                utcOffset = Math.abs(utcOffset);
571
572
                // Time Zone (+/-hh:mm)
573
574
                String numberHours = String.valueOf(utcOffset / 60);
575
576
                if (numberHours.length() == 1)
577
                    currentTimeStamp.append("0");
578
579
                currentTimeStamp.append(numberHours);
580
                currentTimeStamp.append(":");
581
582
                String numberMinutes = String.valueOf(utcOffset % 60);
583
584
                if (numberMinutes.length() == 1)
585
                    currentTimeStamp.append("0");
586
587
                currentTimeStamp.append(numberMinutes);
588
589
                return true;
616
                return true;
590
            }
617
            }
591
        }
618
        }
(-)config/Apache/error/v1.3.26/static.adapter (-2 / +3 lines)
Lines 26-31 Link Here
26
        <pu:Property propertyName="fileName" propertyValue=""/>
26
        <pu:Property propertyName="fileName" propertyValue=""/>
27
        <pu:Property propertyName="parserClassName" propertyValue="org.eclipse.hyades.logging.parsers.ApacheErrorLogParser"/>
27
        <pu:Property propertyName="parserClassName" propertyValue="org.eclipse.hyades.logging.parsers.ApacheErrorLogParser"/>
28
        <pu:Property propertyName="version" propertyValue="default"/>
28
        <pu:Property propertyName="version" propertyValue="default"/>
29
        <pu:Property propertyName="timezone" propertyValue=""/>
29
        <sensor:StaticParserSensor directory="" fileName="" parserClassName="org.eclipse.hyades.logging.parsers.ApacheErrorLogParser"/>
30
        <sensor:StaticParserSensor directory="" fileName="" parserClassName="org.eclipse.hyades.logging.parsers.ApacheErrorLogParser"/>
30
      </cc:Sensor>
31
      </cc:Sensor>
31
      <cc:Outputter description="Static Parser Outputter" uniqueID="AdapterStaticParserOutputterID1" type="LoggingAgentOutputter">
32
      <cc:Outputter description="Static Parser Outputter" uniqueID="AdapterStaticParserOutputterID1" type="LoggingAgentOutputter">
Lines 33-44 Link Here
33
        <pu:Property propertyName="waitUntilLoggingTime" propertyValue="15000"/>
34
        <pu:Property propertyName="waitUntilLoggingTime" propertyValue="15000"/>
34
        <op:LoggingAgentOutputterType agentName="Apache HTTP Server V1.3.20, V1.3.26, V2.0 error log files" waitUntilLoggingTime="15000"/>
35
        <op:LoggingAgentOutputterType agentName="Apache HTTP Server V1.3.20, V1.3.26, V2.0 error log files" waitUntilLoggingTime="15000"/>
35
      </cc:Outputter>
36
      </cc:Outputter>
36
      <cc:Outputter description="CBE File Outputter" uniqueID="ND2DA2480E9C11DB8000DF587DEE0353" disabled="true" type="SingleFileOutputter">
37
      <cc:Outputter description="CBE File Outputter" disabled="true" uniqueID="ND2DA2480E9C11DB8000DF587DEE0353" type="SingleFileOutputter">
37
        <pu:Property propertyName="directory" propertyValue="."/>
38
        <pu:Property propertyName="directory" propertyValue="."/>
38
        <pu:Property propertyName="fileName" propertyValue="example.out"/>
39
        <pu:Property propertyName="fileName" propertyValue="example.out"/>
39
        <op:SingleFileOutputterType directory="." fileName="example.out"/>
40
        <op:SingleFileOutputterType directory="." fileName="example.out"/>
40
      </cc:Outputter>
41
      </cc:Outputter>
41
      <cc:Outputter description="CBE Logging Agent Outputter" uniqueID="NEF1E7880E9C11DB8000DF587DEE0353" disabled="true" type="LoggingAgentOutputter">
42
      <cc:Outputter description="CBE Logging Agent Outputter" disabled="true" uniqueID="NEF1E7880E9C11DB8000DF587DEE0353" type="LoggingAgentOutputter">
42
        <pu:Property propertyName="agentName" propertyValue="Default CBE Logging Agent"/>
43
        <pu:Property propertyName="agentName" propertyValue="Default CBE Logging Agent"/>
43
        <op:LoggingAgentOutputterType agentName="Default CBE Logging Agent"/>
44
        <op:LoggingAgentOutputterType agentName="Default CBE Logging Agent"/>
44
      </cc:Outputter>
45
      </cc:Outputter>

Return to bug 203622