You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OhmFormatter.java 1010B

12345678910111213141516171819202122232425262728293031323334
  1. package grafikchat.ohmlogger;
  2. import java.text.DateFormat;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. import java.util.logging.*;
  6. /**
  7. * Formatter with custom format
  8. *
  9. * @author marian
  10. */
  11. class OhmFormatter extends SimpleFormatter {
  12. private static final DateFormat df = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss.SSS");
  13. /**
  14. * Format message to specified format
  15. * @param record Tecord to format
  16. * @return Formatted string
  17. */
  18. @Override
  19. public String format(LogRecord record) {
  20. StringBuilder builder;
  21. builder = new StringBuilder(1000);
  22. builder.append(df.format(new Date(record.getMillis()))).append(" | ");
  23. builder.append(record.getLevel()).append(" | ");
  24. builder.append(record.getSourceClassName()).append(" | ");
  25. builder.append(record.getSourceMethodName()).append(" | ");
  26. builder.append(formatMessage(record)).append(" |");
  27. builder.append("\n");
  28. return builder.toString();
  29. }
  30. }