コード例 #1
0
  @Test
  public void testRemoveUnfinishedLeftovers_multipleFolders_tooManyFinalRecords() throws Throwable {
    testRemoveUnfinishedLeftovers_multipleFolders_errorConditions(
        txn -> {
          List<File> logFiles = txn.logFiles();
          Assert.assertEquals(2, logFiles.size());

          // insert mismatched records
          FileUtils.append(logFiles.get(0), LogRecord.makeCommit(System.currentTimeMillis()).raw);
          FileUtils.append(logFiles.get(1), LogRecord.makeCommit(System.currentTimeMillis()).raw);
          FileUtils.append(logFiles.get(1), LogRecord.makeCommit(System.currentTimeMillis()).raw);
        },
        false);
  }
コード例 #2
0
ファイル: LoggingUtils.java プロジェクト: pdewan/SelfOptSys
 public String format(LogRecord record) {
   Calendar c = Calendar.getInstance();
   c.setTimeInMillis(record.getMillis());
   String message =
       "["
           + c.getTime().toString()
           + "]"
           + " "
           + record.getLevel()
           + ":"
           + " "
           + record.getMessage()
           + "\n";
   return message;
 }
コード例 #3
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();
 }
コード例 #4
0
  @Test
  public void testRemoveUnfinishedLeftovers_multipleFolders_partialNonFinalRecord_second()
      throws Throwable {
    testRemoveUnfinishedLeftovers_multipleFolders_errorConditions(
        txn -> {
          List<File> logFiles = txn.logFiles();
          Assert.assertEquals(2, logFiles.size());

          // insert a partial sstable record and a full commit record
          String sstableRecord =
              LogRecord.make(LogRecord.Type.ADD, Collections.emptyList(), 0, "abc").raw;
          int toChop = sstableRecord.length() / 2;
          FileUtils.append(logFiles.get(0), sstableRecord);
          FileUtils.append(
              logFiles.get(1), sstableRecord.substring(0, sstableRecord.length() - toChop));
          String finalRecord = LogRecord.makeCommit(System.currentTimeMillis()).raw;
          FileUtils.append(logFiles.get(0), finalRecord);
          FileUtils.append(logFiles.get(1), finalRecord);
        },
        false);
  }
コード例 #5
0
  @Test
  public void testRemoveUnfinishedLeftovers_multipleFolders_missingFinalRecords_second()
      throws Throwable {
    testRemoveUnfinishedLeftovers_multipleFolders_errorConditions(
        txn -> {
          List<File> logFiles = txn.logFiles();
          Assert.assertEquals(2, logFiles.size());

          // insert only one commit record
          FileUtils.append(logFiles.get(1), LogRecord.makeCommit(System.currentTimeMillis()).raw);
        },
        true);
  }
コード例 #6
0
ファイル: ConsoleManager.java プロジェクト: BungMc/Bung
    @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("] ");
      if (color) {
        builder.append(colorize(formatMessage(record)));
      } else {
        builder.append(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();
    }
コード例 #7
0
  @Test
  public void testRemoveUnfinishedLeftovers_multipleFolders_partialFinalRecords_second()
      throws Throwable {
    testRemoveUnfinishedLeftovers_multipleFolders_errorConditions(
        txn -> {
          List<File> logFiles = txn.logFiles();
          Assert.assertEquals(2, logFiles.size());

          // insert a full record and a partial one
          String finalRecord = LogRecord.makeCommit(System.currentTimeMillis()).raw;
          int toChop = finalRecord.length() / 2;
          FileUtils.append(logFiles.get(0), finalRecord);
          FileUtils.append(
              logFiles.get(1), finalRecord.substring(0, finalRecord.length() - toChop));
        },
        true);
  }
コード例 #8
0
 public boolean isLoggable(LogRecord rec) {
   return isLogging && logValue(rec.getLevel()) >= logValue(minLogLevel);
 }
コード例 #9
0
 public void publish(LogRecord rec) {
   String msg = String.format("%s: %s", rec.getLevel().toString(), rec.getMessage());
   logstream.println(msg);
 }