ConsoleLogFormatter.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.util.logging.Formatter;
  17. import java.util.logging.LogRecord;
  18. import com.l2jserver.util.StringUtil;
  19. import com.l2jserver.util.Util;
  20. /**
  21. * This class ...
  22. *
  23. * @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:08 $
  24. */
  25. public class ConsoleLogFormatter extends Formatter
  26. {
  27. // private static final String _ = " ";
  28. private static final String CRLF = "\r\n";
  29. @Override
  30. public String format(LogRecord record)
  31. {
  32. final StringBuilder output = new StringBuilder(500);
  33. // output.append(record.getLevel().getName());
  34. // output.append(_);
  35. // output.append(record.getLoggerName());
  36. // output.append(_);
  37. StringUtil.append(output, record.getMessage(), CRLF);
  38. if (record.getThrown() != null)
  39. {
  40. try
  41. {
  42. StringUtil.append(output, Util.getStackTrace(record.getThrown()), CRLF);
  43. }
  44. catch (Exception ex)
  45. {
  46. }
  47. }
  48. return output.toString();
  49. }
  50. }