コード例 #1
0
  @Override
  public synchronized String format(LogRecord record) {
    StringBuilder sb = new StringBuilder();

    sb.append(dateFormat.format(new Date(record.getMillis())));
    sb.append(' ');
    sb.append(record.getLevel().getLocalizedName());
    sb.append(": ");
    sb.append(formatMessage(record));
    sb.append(LINE_SEPARATOR);

    if (record.getThrown() != null) {
      try {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        record.getThrown().printStackTrace(pw);
        pw.close();
        sb.append(sw.toString());
      } catch (Exception e) {
        // ignore
      }
    }

    return sb.toString();
  }
コード例 #2
0
ファイル: ConsoleManager.java プロジェクト: kitskub/Glowstone
    @Override
    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    public String format(LogRecord record) {
      StringBuilder builder = new StringBuilder();

      builder.append(date.format(record.getMillis()));
      builder.append(" [");
      builder.append(record.getLevel().getLocalizedName().toUpperCase());
      builder.append("] ");
      builder.append(colorize(formatMessage(record)));
      builder.append('\n');

      if (record.getThrown() != null) {
        StringWriter writer = new StringWriter();
        record.getThrown().printStackTrace(new PrintWriter(writer));
        builder.append(writer.toString());
      }

      return builder.toString();
    }
コード例 #3
0
  public String format(LogRecord record) {
    StringBuffer buf = new StringBuffer(1000);
    buf.append(new java.util.Date());
    buf.append(" : ");

    if (Level.INFO != record.getLevel()) {
      buf.append(record.getLevel());
      buf.append(": ");
    }

    buf.append(formatMessage(record));

    if (Util.isWinOS()) {
      buf.append("\r\n");
    } else {
      buf.append("\n");
    }

    return buf.toString();
  }
コード例 #4
0
ファイル: OCSSWRuntimeConfig.java プロジェクト: mg1989/seadas
 @Override
 public String format(LogRecord record) {
   StringWriter sw = new StringWriter();
   PrintWriter pw = new PrintWriter(sw);
   pw.append('[');
   pw.append(record.getLevel().toString());
   pw.append(']');
   pw.append(' ');
   pw.append(LOG_TIME_STAMP_FORMAT.format(new Date(record.getMillis())));
   pw.append(' ');
   pw.append('-');
   pw.append(' ');
   pw.append(record.getMessage());
   Throwable thrown = record.getThrown();
   if (thrown != null) {
     pw.println();
     thrown.printStackTrace(pw);
   }
   pw.println();
   return sw.toString();
 }