view src/goodjava/logger/DateLayout.java @ 1461:e5d48b85351c

start lucene.logging
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 28 Mar 2020 21:30:42 -0600
parents 6fc083e1d08c
children
line wrap: on
line source

package goodjava.logger;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;


public final class DateLayout implements Layout {
	private final Date date = new Date();
	private final DateFormat dateFormat;

	public DateLayout(String pattern) {
		dateFormat = new SimpleDateFormat(pattern);
	}

	public synchronized String format(LoggingEvent event) {
		date.setTime(event.time);
		return dateFormat.format(date);
	}
}