View Javadoc

1   package de.desy.acop.video.displayer;
2   
3   import java.text.DateFormat;
4   import java.text.SimpleDateFormat;
5   import java.util.Date;
6   import java.util.logging.Formatter;
7   import java.util.logging.LogRecord;
8   
9   /**
10   * 
11   * <code>LogFormatter</code> is the default formatter to be used with the image logger.
12   * It formats the message with the timestamp at front.
13   *
14   * @author <a href="mailto:jaka.bobnar@cosylab.com">Jaka Bobnar</a>
15   *
16   */
17  public class LogFormatter extends Formatter {
18  
19  	private DateFormat format = new SimpleDateFormat("dd.MM.yy HH:mm:ss.SSS z");
20  	
21  	/*
22  	 * (non-Javadoc)
23  	 * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
24  	 */
25  	@Override
26  	public String format(LogRecord record) {
27  		StringBuilder retVal = new StringBuilder();
28  		retVal.append('[');
29  		retVal.append(format.format(new Date(record.getMillis())));
30  		retVal.append("] ");
31  		retVal.append(record.getMessage());
32  		retVal.append("\n");
33  		return retVal.toString();
34  	}
35  }