This project has retired. For details please refer to its Attic page.
LogEntry xref
View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.chukwa.extraction.demux.processor.mapper;
19  
20  import java.text.ParseException;
21  import java.text.SimpleDateFormat;
22  import java.util.Date;
23  
24  public class LogEntry {
25  	private final static SimpleDateFormat sdf = new SimpleDateFormat(
26  			"yyyy-MM-dd HH:mm");
27  
28  	private Date date;
29  	private String logLevel;
30  	private String className;
31  	private String body;
32  
33  	public LogEntry(String recordEntry) throws ParseException {
34  		String dStr = recordEntry.substring(0, 23);
35  		date = sdf.parse(dStr);
36  		int start = 24;
37  		int idx = recordEntry.indexOf(' ', start);
38  		logLevel = recordEntry.substring(start, idx);
39  		start = idx + 1;
40  		idx = recordEntry.indexOf(' ', start);
41  		className = recordEntry.substring(start, idx - 1);
42  		body = recordEntry.substring(idx + 1);
43  	}
44  
45  	public Date getDate() {
46  		return date;
47  	}
48  
49  	public void setDate(Date date) {
50  		this.date = date;
51  	}
52  
53  	public String getLogLevel() {
54  		return logLevel;
55  	}
56  
57  	public String getClassName() {
58  		return className;
59  	}
60  
61  	public String getBody() {
62  		return body;
63  	}
64  }