/** Implements logging of an IStatus object, recursively as needed. */ private static void doLog(IStatus status) { if (status.isOK()) return; Throwable t = status.getException(); if (status.getSeverity() == IStatus.ERROR) { logger.error(status.getMessage(), t); } else if (status.getSeverity() == IStatus.WARNING) { logger.warn(status.getMessage(), t); } else { logger.info(status.getMessage(), t); } int stackCode = t instanceof CoreException ? 1 : 0; // ensure a substatus inside a CoreException is properly logged if (stackCode == 1) { IStatus coreStatus = ((CoreException) t).getStatus(); if (coreStatus != null) { doLog(coreStatus); } } if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { doLog(children[i]); } } }
public static void log(IStatus status) { if (logger != null) { doLog(status); } else { System.out.println(status.getMessage()); if (status.getException() != null) status.getException().printStackTrace(); } }