package org.cytoscape.work.internal.task;

import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Level;

import org.ops4j.pax.logging.spi.PaxAppender;
import org.ops4j.pax.logging.spi.PaxLevel;
import org.ops4j.pax.logging.spi.PaxLoggingEvent;

import org.cytoscape.work.TaskMonitor;

public class CyUserLogAppender implements PaxAppender {
  final TaskStatusBar statusBar;
  final TaskHistory history;

  public CyUserLogAppender(final TaskStatusBar statusBar, final TaskHistory history) {
    this.statusBar = statusBar;
    this.history = history;
  }

  public void doAppend(final PaxLoggingEvent event) {
    final TaskMonitor.Level level = getCorrespondingLevel(event.getLevel().toInt());
    final String message = event.getMessage();

    history.addUnnestedMessage(level, message);
    statusBar.setTitle(level, message);
  }

  private static TaskMonitor.Level getCorrespondingLevel(final int level) {
    switch (level) {
      case 40000:
        return TaskMonitor.Level.ERROR;
      case 30000:
        return TaskMonitor.Level.WARN;
      default:
        return TaskMonitor.Level.INFO;
    }
  }
}

@@ -47,281 +47,134 @@
 ort 
-java.util.logging.Handler;%0Aimport java.util.logging.LogRecord;%0Aimport java.util.logging.Level;%0A%0Aimport org.ops4j.pax.logging.spi.PaxAppender;%0Aimport org.ops4j.pax.logging.spi.PaxLevel;%0Aimport org.ops4j.pax.logging.spi.PaxLoggingEvent;%0A%0Aimport org.cytoscape.work.TaskMonitor
+org.cytoscape.work.TaskMonitor;%0Aimport org.ops4j.pax.logging.spi.PaxAppender;%0Aimport org.ops4j.pax.logging.spi.PaxLoggingEvent
 ;%0A%0Ap
@@ -718,16 +718,154 @@
 ssage);%0A
+    %0A    if(event.getThrowableStrRep() != null) %7B%0A    %09for(String line: event.getThrowableStrRep())%0A    %09%09System.err.println(line);%0A    %7D%0A
   %7D%0A%0A  p

Output user log exceptions to standard error. Refs #2521