1 /* 2 LogFormatter.java 3 Creation date : 15/05/2007 4 Copyright © Benjamin Croizet (graffity2199@yahoo.fr) 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 or GNU Lesser General Public License as published by the 9 Free Software Foundation; either version 3 of the License, 10 or (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received copies of the GNU General Public License 18 and GNU Lesser General Public License along with this program; 19 if not, write to the Free Software Foundation, Inc., 20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 http://www.fsf.org/licensing/licenses/gpl.html 22 http://www.gnu.org/licenses/lgpl.html 23 */ 24 25 package net.sourceforge.plantumldependency.common.utils.log; 26 27 import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.SPACE_CHAR; 28 import static net.sourceforge.plantumldependency.common.constants.CommonConstants.LINE_SEPARATOR; 29 30 import java.util.Date; 31 import java.util.logging.Handler; 32 import java.util.logging.LogRecord; 33 import java.util.logging.SimpleFormatter; 34 35 /** 36 * The class which manages to format log records. 37 * 38 * @author Benjamin Croizet (graffity2199@yahoo.fr) 39 * @since 0.4 40 * @version 0.7 41 */ 42 public class LogFormatter extends SimpleFormatter { 43 44 /** 45 * {@inheritDoc} 46 * 47 * @since 0.4 48 */ 49 @Override 50 public synchronized String format(final LogRecord record) { 51 return super.format(record).replaceFirst(LINE_SEPARATOR, SPACE_CHAR); 52 } 53 54 /** 55 * {@inheritDoc} 56 * 57 * @since 0.4 58 */ 59 @Override 60 public String getHead(final Handler h) { 61 return "Program launched at " + new Date() + LINE_SEPARATOR; 62 } 63 64 /** 65 * {@inheritDoc} 66 * 67 * @since 0.4 68 */ 69 @Override 70 public String getTail(final Handler h) { 71 return "Program finished at " + new Date() + LINE_SEPARATOR + LINE_SEPARATOR; 72 } 73 }