1 11 package org.eclipse.core.internal.runtime; 12 13 import java.util.ArrayList ; 14 import org.eclipse.core.runtime.*; 15 import org.eclipse.osgi.framework.log.FrameworkLog; 16 import org.eclipse.osgi.framework.log.FrameworkLogEntry; 17 18 25 public class PlatformLogWriter implements ILogListener { 26 private final FrameworkLog frameworkLog; 27 28 public PlatformLogWriter(FrameworkLog frameworkLog) { 29 this.frameworkLog = frameworkLog; 30 } 31 32 35 public synchronized void logging(IStatus status, String plugin) { 36 frameworkLog.log(getLog(status)); 37 } 38 39 protected FrameworkLogEntry getLog(IStatus status) { 40 Throwable t = status.getException(); 41 ArrayList childlist = new ArrayList (); 42 43 int stackCode = t instanceof CoreException ? 1 : 0; 44 if (stackCode == 1) { 46 IStatus coreStatus = ((CoreException) t).getStatus(); 47 if (coreStatus != null) { 48 childlist.add(getLog(coreStatus)); 49 } 50 } 51 52 if (status.isMultiStatus()) { 53 IStatus[] children = status.getChildren(); 54 for (int i = 0; i < children.length; i++) { 55 childlist.add(getLog(children[i])); 56 } 57 } 58 59 FrameworkLogEntry[] children = (FrameworkLogEntry[]) (childlist.size() == 0 ? null : childlist.toArray(new FrameworkLogEntry[childlist.size()])); 60 61 return new FrameworkLogEntry(status.getPlugin(), status.getSeverity(), status.getCode(), status.getMessage(), stackCode, t, children); 62 } 63 } 64 | Popular Tags |