Exemplo n.º 1
0
 @Override
 public String format(LogRecord logRecord) {
   final StringBuilder result = new StringBuilder();
   result.append(logRecord.getSequenceNumber());
   result.append('[');
   result.append(logRecord.getLevel());
   result.append("] ");
   result.append(logRecord.getSourceClassName().replace("com.microsoft.reef", "c.m.r"));
   result.append('.');
   result.append(logRecord.getSourceMethodName());
   result.append(": ");
   result.append(simpleFormatter.formatMessage(logRecord));
   result.append('\n');
   return result.toString();
 }
  /**
   * Flushes the log buffer, logging each buffered log message using the reef-bridge log function.
   */
  private void logAll() {
    synchronized (this) {
      final StringBuilder sb = new StringBuilder();
      Level highestLevel = Level.FINEST;
      for (final LogRecord record : this.logs) {
        sb.append(formatter.format(record));
        sb.append("\n");
        if (record.getLevel().intValue() > highestLevel.intValue()) {
          highestLevel = record.getLevel();
        }
      }
      try {
        final int level = getLevel(highestLevel);
        NativeInterop.clrBufferedLog(level, sb.toString());
      } catch (Exception e) {
        System.err.println("Failed to perform CLRBufferedLogHandler");
      }

      this.logs.clear();
    }
  }
Exemplo n.º 3
0
 /*
  * (non-Javadoc)
  *
  * @see
  * accessories.plugins.LogFileLogHandler.LogReceiver#receiveLog(java.util
  * .logging.LogRecord)
  */
 public void receiveLog(final LogRecord record) {
   String msg = mSimpleFormatter.format(record);
   mUpdateTextAreaThread.addToInbox(msg);
 }