Examples of FrameworkLog


Examples of org.eclipse.osgi.framework.log.FrameworkLog

   */
  public IPath getLogLocation() throws IllegalStateException {
    //make sure the log location is initialized if the instance location is known
    if (isInstanceLocationSet())
      assertLocationInitialized();
    FrameworkLog log = Activator.getDefault().getFrameworkLog();
    if (log != null) {
      java.io.File file = log.getFile();
      if (file != null)
        return new Path(file.getAbsolutePath());
    }
    if (location == null)
      throw new IllegalStateException(CommonMessages.meta_instanceDataUnspecified);
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    // set the log file location now that we created the data area
    IPath logPath = location.append(F_META_AREA).append(F_LOG);
    try {
      Activator activator = Activator.getDefault();
      if (activator != null) {
        FrameworkLog log = activator.getFrameworkLog();
        if (log != null)
          log.setFile(logPath.toFile(), true);
        else if (debug())
          System.out.println("ERROR: Unable to acquire log service. Application will proceed, but logging will be disabled."); //$NON-NLS-1$
      }
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

  public static boolean isRunning() {
    return running;
  }

  protected static FrameworkLog createFrameworkLog() {
    FrameworkLog frameworkLog;
    String logFileProp = FrameworkProperties.getProperty(EclipseStarter.PROP_LOGFILE);
    if (logFileProp != null) {
      frameworkLog = new EclipseLog(new File(logFileProp));
    } else {
      Location location = LocationManager.getConfigurationLocation();
      File configAreaDirectory = null;
      if (location != null)
        // TODO assumes the URL is a file: url
        configAreaDirectory = new File(location.getURL().getFile());

      if (configAreaDirectory != null) {
        String logFileName = Long.toString(System.currentTimeMillis()) + ".log"; //$NON-NLS-1$
        File logFile = new File(configAreaDirectory, logFileName);
        FrameworkProperties.setProperty(EclipseStarter.PROP_LOGFILE, logFile.getAbsolutePath());
        frameworkLog = new EclipseLog(logFile);
      } else
        frameworkLog = new EclipseLog();
    }
    if ("true".equals(FrameworkProperties.getProperty(EclipseStarter.PROP_CONSOLE_LOG))) //$NON-NLS-1$
      frameworkLog.setConsoleLog(true);
    return frameworkLog;
  }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    }
  }

  private static void logUnresolvedBundles(Bundle[] bundles) {
    State state = adaptor.getState();
    FrameworkLog logService = adaptor.getFrameworkLog();
    StateHelper stateHelper = adaptor.getPlatformAdmin().getStateHelper();

    // first lets look for missing leaf constraints (bug 114120)
    VersionConstraint[] leafConstraints = stateHelper.getUnsatisfiedLeaves(state.getBundles());
    // hash the missing leaf constraints by the declaring bundles
    Map missing = new HashMap();
    for (int i = 0; i < leafConstraints.length; i++) {
      // only include non-optional and non-dynamic constraint leafs
      if (leafConstraints[i] instanceof BundleSpecification && ((BundleSpecification) leafConstraints[i]).isOptional())
        continue;
      if (leafConstraints[i] instanceof ImportPackageSpecification) {
        if (ImportPackageSpecification.RESOLUTION_OPTIONAL.equals(((ImportPackageSpecification) leafConstraints[i]).getDirective(Constants.RESOLUTION_DIRECTIVE)))
          continue;
        if (ImportPackageSpecification.RESOLUTION_DYNAMIC.equals(((ImportPackageSpecification) leafConstraints[i]).getDirective(Constants.RESOLUTION_DIRECTIVE)))
          continue;
      }
      BundleDescription bundle = leafConstraints[i].getBundle();
      ArrayList constraints = (ArrayList) missing.get(bundle);
      if (constraints == null) {
        constraints = new ArrayList();
        missing.put(bundle, constraints);
      }
      constraints.add(leafConstraints[i]);
    }

    // found some bundles with missing leaf constraints; log them first
    if (missing.size() > 0) {
      FrameworkLogEntry[] rootChildren = new FrameworkLogEntry[missing.size()];
      int rootIndex = 0;
      for (Iterator iter = missing.keySet().iterator(); iter.hasNext(); rootIndex++) {
        BundleDescription description = (BundleDescription) iter.next();
        String symbolicName = description.getSymbolicName() == null ? FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME : description.getSymbolicName();
        String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, description.getLocation());
        ArrayList constraints = (ArrayList) missing.get(description);
        FrameworkLogEntry[] logChildren = new FrameworkLogEntry[constraints.size()];
        for (int i = 0; i < logChildren.length; i++)
          logChildren[i] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage((VersionConstraint) constraints.get(i)), 0, null, null);
        rootChildren[rootIndex] = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren);
      }
      logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED, 0, null, rootChildren));
    }

    // There may be some bundles unresolved for other reasons, causing the system to be unresolved
    // log all unresolved constraints now
    ArrayList allChildren = new ArrayList();
    for (int i = 0; i < bundles.length; i++)
      if (bundles[i].getState() == Bundle.INSTALLED) {
        String symbolicName = bundles[i].getSymbolicName() == null ? FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME : bundles[i].getSymbolicName();
        String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, bundles[i]);
        BundleDescription description = state.getBundle(bundles[i].getBundleId());
        // for some reason, the state does not know about that bundle
        if (description == null)
          continue;
        FrameworkLogEntry[] logChildren = null;
        VersionConstraint[] unsatisfied = stateHelper.getUnsatisfiedConstraints(description);
        if (unsatisfied.length > 0) {
          // the bundle wasn't resolved due to some of its constraints were unsatisfiable
          logChildren = new FrameworkLogEntry[unsatisfied.length];
          for (int j = 0; j < unsatisfied.length; j++)
            logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage(unsatisfied[j]), 0, null, null);
        } else {
          ResolverError[] resolverErrors = state.getResolverErrors(description);
          if (resolverErrors.length > 0) {
            logChildren = new FrameworkLogEntry[resolverErrors.length];
            for (int j = 0; j < resolverErrors.length; j++)
              logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, resolverErrors[j].toString(), 0, null, null);
          }
        }

        allChildren.add(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren));
      }
    if (allChildren.size() > 0)
      logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ALL_NOT_RESOLVED, 0, null, (FrameworkLogEntry[]) allChildren.toArray(new FrameworkLogEntry[allChildren.size()])));
  }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    for (int i = 0; i < adaptorHooks.length; i++) {
      log = adaptorHooks[i].createFrameworkLog();
      if (log != null)
        return log;
    }
    log = new FrameworkLog() {
      public void log(FrameworkEvent frameworkEvent) {
        log(new FrameworkLogEntry(frameworkEvent.getBundle().getSymbolicName() == null ? frameworkEvent.getBundle().getLocation() : frameworkEvent.getBundle().getSymbolicName(), FrameworkLogEntry.ERROR, 0, "FrameworkEvent.ERROR", 0, frameworkEvent.getThrowable(), null)); //$NON-NLS-1$
      }

      public void log(FrameworkLogEntry logEntry) {
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    // TODO Auto-generated method stub

  }

  public FrameworkLog createFrameworkLog() {
    FrameworkLog frameworkLog;
    String logFileProp = FrameworkProperties.getProperty(EclipseStarter.PROP_LOGFILE);
    if (logFileProp != null) {
      frameworkLog = new EclipseLog(new File(logFileProp));
    } else {
      Location location = LocationManager.getConfigurationLocation();
      File configAreaDirectory = null;
      if (location != null)
        // TODO assumes the URL is a file: url
        configAreaDirectory = new File(location.getURL().getFile());

      if (configAreaDirectory != null) {
        String logFileName = Long.toString(System.currentTimeMillis()) + EclipseLogHook.LOG_EXT;
        File logFile = new File(configAreaDirectory, logFileName);
        FrameworkProperties.setProperty(EclipseStarter.PROP_LOGFILE, logFile.getAbsolutePath());
        frameworkLog = new EclipseLog(logFile);
      } else
        frameworkLog = new EclipseLog();
    }
    if ("true".equals(FrameworkProperties.getProperty(EclipseStarter.PROP_CONSOLE_LOG))) //$NON-NLS-1$
      frameworkLog.setConsoleLog(true);
    return frameworkLog;
  }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

  }

  public void publishFrameworkEventPrivileged(FrameworkEvent event) {
    /* if the event is an error then it should be logged */
    if (event.getType() == FrameworkEvent.ERROR) {
      FrameworkLog frameworkLog = adaptor.getFrameworkLog();
      if (frameworkLog != null)
        frameworkLog.log(event);
    }
    /* queue to hold set of listeners */
    ListenerQueue listeners = new ListenerQueue(eventManager);
    /* queue to hold set of BundleContexts w/ listeners */
    ListenerQueue contexts = new ListenerQueue(eventManager);
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    processCommandLine(getEnvironmentInfoService().getNonFrameworkArgs());
    initializeDebugFlags();
    initialized = true;
    getMetaArea();
    initializeAuthorizationHandler();
    FrameworkLog log = getFrameworkLog();
    if (log != null) {
      platformLog = new PlatformLogWriter(getFrameworkLog());
      addLogListener(platformLog);
    }
    else
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    setSystem(true);
    setPriority(DECORATE);
    BundleContext context = PlatformActivator.getContext();
    String filter = '(' + FrameworkLog.SERVICE_PERFORMANCE + '=' + Boolean.TRUE.toString() + ')';
    ServiceReference[] references;
    FrameworkLog perfLog = null;
    try {
      references = context.getServiceReferences(FrameworkLog.class.getName(), filter);
      if (references != null && references.length > 0) {
        //just take the first matching service
        perfLog = (FrameworkLog) context.getService(references[0]);
        //make sure correct location is set
        IPath logLocation = Platform.getLogFileLocation();
        logLocation = logLocation.removeLastSegments(1).append("performance.log"); //$NON-NLS-1$
        perfLog.setFile(logLocation.toFile(), false);
      }
    } catch (Exception e) {
      IStatus error = new Status(IStatus.ERROR, Platform.PI_RUNTIME, 1, "Error loading performance log", e); //$NON-NLS-1$
      InternalPlatform.getDefault().log(error);
    }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    public void logSevere(SVNLogType logType, Throwable th) {
        log(logType, th, Level.SEVERE);
    }

    public void log(SVNLogType logType, String message, byte[] data) {
        FrameworkLog log = myActivator.getFrameworkLog();
        if (log == null) {
            return;
        }
        if (isTraceEnabled()) {
            FrameworkLogEntry entry = null;
            String dataMessage = null;
            try {
                dataMessage = new String(data, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                dataMessage = new String(data);
            }
            message += " : " + dataMessage;
            message = getMessage(logType, message);
            entry = myActivator.createFrameworkLogEntry(FrameworkEvent.INFO, message, null);
            if (entry != null) {
                log.log(entry);
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.