Mercurial Hosting > luan
diff src/goodjava/logger/DateLayout.java @ 1448:6fc083e1d08c
start logger
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 23 Feb 2020 18:14:32 -0700 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/goodjava/logger/DateLayout.java Sun Feb 23 18:14:32 2020 -0700 @@ -0,0 +1,20 @@ +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); + } +}