FileLogFormatter.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.log;
  16. import java.text.SimpleDateFormat;
  17. import java.util.Date;
  18. import java.util.logging.Formatter;
  19. import java.util.logging.LogRecord;
  20. import javolution.text.TextBuilder;
  21. /**
  22. * This class ...
  23. *
  24. * @version $Revision: 1.1.4.1 $ $Date: 2005/03/27 15:30:08 $
  25. */
  26. public class FileLogFormatter extends Formatter
  27. {
  28. /* (non-Javadoc)
  29. * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
  30. */
  31. private static final String CRLF = "\r\n";
  32. private static final String _ = "\t";
  33. private SimpleDateFormat dateFmt = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss,SSS");
  34. @Override
  35. public String format(LogRecord record)
  36. {
  37. TextBuilder output = new TextBuilder();
  38. return output
  39. .append(dateFmt.format(new Date(record.getMillis())))
  40. .append(_)
  41. .append(record.getLevel().getName())
  42. .append(_)
  43. .append(record.getThreadID())
  44. .append(_)
  45. .append(record.getLoggerName())
  46. .append(_)
  47. .append(record.getMessage())
  48. .append(CRLF)
  49. .toString();
  50. }
  51. }