Cleanup / reduce log output from boot.ls classpath listeners
See https://github.com/spring-projects/sts4/issues/798
This commit is contained in:
@@ -56,15 +56,30 @@ public interface Logger {
|
||||
public void log(Exception e) {
|
||||
e.printStackTrace(printwriter);
|
||||
}
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
log("DEBUG:" + message);
|
||||
}
|
||||
}
|
||||
|
||||
static Logger forEclipsePlugin(Supplier<Plugin> instance) {
|
||||
static Logger forEclipsePlugin(Supplier<Plugin> _plugin) {
|
||||
return new Logger() {
|
||||
|
||||
private Plugin plugin = null;
|
||||
private boolean DEBUG = false;
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
init();
|
||||
if (DEBUG) {
|
||||
log(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
init();
|
||||
try {
|
||||
Plugin plugin = instance.get();
|
||||
plugin.getLog().log(new Status(IStatus.INFO, plugin.getBundle().getSymbolicName(), message));
|
||||
} catch (Exception ignore) {
|
||||
//Eclipse state is fubar... send log message someplace else.
|
||||
@@ -74,19 +89,28 @@ public interface Logger {
|
||||
|
||||
@Override
|
||||
public void log(Exception e) {
|
||||
init();
|
||||
try {
|
||||
Plugin plugin = instance.get();
|
||||
plugin.getLog().log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), "", e));
|
||||
} catch (Exception ignore) {
|
||||
//Eclipse state is fubar... send log message someplace else.
|
||||
DEFAULT.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (plugin==null) {
|
||||
plugin = _plugin.get();
|
||||
DEBUG = Boolean.getBoolean(plugin.getBundle().getSymbolicName() + ".DEBUG");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
void debug(String message);
|
||||
|
||||
public static class TestLogger extends DefaultLogger {
|
||||
|
||||
private Exception firstError;
|
||||
|
||||
@@ -165,7 +165,7 @@ public class ClasspathListenerManager {
|
||||
|
||||
public ClasspathListenerManager(Logger logger, ClasspathListener listener) {
|
||||
this.logger = logger;
|
||||
this.logger.log("Setting up ClasspathListenerManager");
|
||||
this.logger.debug("Setting up ClasspathListenerManager");
|
||||
this.listener = listener;
|
||||
JavaCore.addElementChangedListener(myListener=new MyListener(), ElementChangedEvent.POST_CHANGE);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ClasspathUtil {
|
||||
}
|
||||
}
|
||||
Classpath classpath = new Classpath(cpEntries);
|
||||
logger.log("classpath=" + classpath.getEntries().size() + " entries");
|
||||
logger.debug("classpath=" + classpath.getEntries().size() + " entries");
|
||||
return classpath;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ public class ReusableClasspathListenerHandler {
|
||||
this.projectSorterFactory = projectSorterFactory;
|
||||
this.conn = conn;
|
||||
this.notificationsSentCallbacks = new ListenerList<>();
|
||||
logger.log("Instantiating ReusableClasspathListenerHandler");
|
||||
}
|
||||
|
||||
private class CallbackJob extends Job {
|
||||
@@ -128,7 +127,7 @@ public class ReusableClasspathListenerHandler {
|
||||
}
|
||||
|
||||
private void sendInitialEvents(String callbackCommandId, IProject[] projects) {
|
||||
logger.log("Scheduling initial event for all projects ...");
|
||||
logger.debug("Scheduling initial event for all projects ...");
|
||||
|
||||
Set<String> callbackIds = Collections.singleton(callbackCommandId);
|
||||
|
||||
@@ -146,7 +145,7 @@ public class ReusableClasspathListenerHandler {
|
||||
logger.log(e);
|
||||
}
|
||||
}
|
||||
logger.log("Scheduling initial event for all projects DONE");
|
||||
logger.debug("Scheduling initial event for all projects DONE");
|
||||
}
|
||||
|
||||
private IProject[] getSortedProjects() {
|
||||
@@ -167,7 +166,7 @@ public class ReusableClasspathListenerHandler {
|
||||
}
|
||||
|
||||
public synchronized void unsubscribe(String callbackCommandId) {
|
||||
logger.log("unsubscribing from classpath changes: " + callbackCommandId);
|
||||
logger.debug("unsubscribing from classpath changes: " + callbackCommandId);
|
||||
subscribers.remove(callbackCommandId);
|
||||
|
||||
if (subscribers.isEmpty() && classpathListener != null) {
|
||||
@@ -175,7 +174,7 @@ public class ReusableClasspathListenerHandler {
|
||||
classpathListener = null;
|
||||
}
|
||||
|
||||
logger.log("subsribers = " + subscribers);
|
||||
logger.debug("subsribers = " + subscribers);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
@@ -186,9 +185,9 @@ public class ReusableClasspathListenerHandler {
|
||||
private Subscriptions subscriptions = new Subscriptions();
|
||||
|
||||
public Object removeClasspathListener(String callbackCommandId) {
|
||||
logger.log("ClasspathListenerHandler removeClasspathListener " + callbackCommandId);
|
||||
logger.debug("ClasspathListenerHandler removeClasspathListener " + callbackCommandId);
|
||||
subscriptions.unsubscribe(callbackCommandId);
|
||||
logger.log("ClasspathListenerHandler removeClasspathListener " + callbackCommandId + " => OK");
|
||||
logger.debug("ClasspathListenerHandler removeClasspathListener " + callbackCommandId + " => OK");
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@@ -198,9 +197,9 @@ public class ReusableClasspathListenerHandler {
|
||||
}
|
||||
|
||||
public Object addClasspathListener(String callbackCommandId, boolean isBatched) {
|
||||
logger.log("ClasspathListenerHandler addClasspathListener " + callbackCommandId + "isBatched = "+isBatched);
|
||||
logger.debug("ClasspathListenerHandler addClasspathListener " + callbackCommandId + "isBatched = "+isBatched);
|
||||
subscriptions.subscribe(callbackCommandId, isBatched);
|
||||
logger.log("ClasspathListenerHandler addClasspathListener " + callbackCommandId + " => OK");
|
||||
logger.debug("ClasspathListenerHandler addClasspathListener " + callbackCommandId + " => OK");
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ public class SendClasspathNotificationsJob extends Job {
|
||||
// So we will just pretend / assume project is always open. If resolving classpath fails because it is not
|
||||
// open... so be it (there will be no classpath... this is expected for closed project, so that is fine).
|
||||
boolean deleted = !(exists && open);
|
||||
logger.log("exists = "+exists +" open = "+open +" => deleted = "+deleted);
|
||||
String projectName = jp.getElementName();
|
||||
|
||||
Classpath classpath = Classpath.EMPTY;
|
||||
@@ -156,14 +155,14 @@ public class SendClasspathNotificationsJob extends Job {
|
||||
|
||||
protected void bufferMessage(URI projectLoc, boolean deleted, String projectName, Classpath classpath) {
|
||||
if (buffer!=null) {
|
||||
logger.log("buffering callback "+callbackCommandId+" "+projectName+" "+deleted+" "+ classpath.getEntries().size());
|
||||
logger.debug("buffering callback "+callbackCommandId+" "+projectName+" "+deleted+" "+ classpath.getEntries().size());
|
||||
buffer.add(ImmutableList.of(projectLoc.toString(), projectName, deleted, classpath));
|
||||
} else {
|
||||
try {
|
||||
logger.log("executing callback "+callbackCommandId+" "+projectName+" "+deleted+" "+ classpath.getEntries().size());
|
||||
logger.debug("executing callback "+callbackCommandId+" "+projectName+" "+deleted+" "+ classpath.getEntries().size());
|
||||
Object r = conn.executeClientCommand(callbackCommandId, projectLoc.toString(), projectName, deleted, classpath);
|
||||
notificationsSentForProjects = ImmutableList.of(projectName);
|
||||
logger.log("executing callback "+callbackCommandId+" SUCCESS ["+r+"]");
|
||||
logger.debug("executing callback "+callbackCommandId+" SUCCESS ["+r+"]");
|
||||
} catch (Exception e) {
|
||||
logger.log("executing callback "+callbackCommandId+" FAILED");
|
||||
logger.log(e);
|
||||
@@ -174,11 +173,11 @@ public class SendClasspathNotificationsJob extends Job {
|
||||
protected void flush() {
|
||||
if (buffer!=null && !buffer.isEmpty()) {
|
||||
try {
|
||||
logger.log("executing callback "+callbackCommandId+" "+buffer.size()+" batched events");
|
||||
logger.debug("executing callback "+callbackCommandId+" "+buffer.size()+" batched events");
|
||||
Object r = conn.executeClientCommand(callbackCommandId, buffer.toArray(new Object[buffer.size()]));
|
||||
notificationsSentForProjects = ImmutableList.copyOf(buffer.stream().filter(l -> l instanceof List)
|
||||
.map(l -> (List<?>) l).map(l -> (String) l.get(1)).collect(Collectors.toList()));
|
||||
logger.log("executing callback "+callbackCommandId+" SUCCESS ["+r+"]");
|
||||
logger.debug("executing callback "+callbackCommandId+" SUCCESS ["+r+"]");
|
||||
} catch (Exception e) {
|
||||
logger.log("executing callback "+callbackCommandId+" FAILED");
|
||||
logger.log(e);
|
||||
|
||||
Reference in New Issue
Block a user