org.eclipse.core.runtime.Platform.getLogFileLocation()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.eclipse.core.runtime.Platform.getLogFileLocation()方法的一些代码示例,展示了Platform.getLogFileLocation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Platform.getLogFileLocation()方法的具体详情如下:
包路径:org.eclipse.core.runtime.Platform
类名称:Platform
方法名:getLogFileLocation

Platform.getLogFileLocation介绍

[英]Returns the location of the platform log file. This file may contain information about errors that have previously occurred during this invocation of the Platform.

It is recommended not to keep this value, as the log location may vary when an instance location is being set.

Note: it is very important that users of this method do not leave the log file open for extended periods of time. Doing so may prevent others from writing to the log file, which could result in important error messages being lost. It is strongly recommended that clients wanting to read the log file for extended periods should copy the log file contents elsewhere, and immediately close the original file.
[中]返回平台日志文件的位置。此文件可能包含有关在此平台调用过程中发生的错误的信息。
建议不要保留此值,因为在设置实例位置时,日志位置可能会有所不同。
注意:此方法的用户不要让日志文件长时间处于打开状态,这一点非常重要。这样做可能会阻止其他人写入日志文件,这可能会导致重要错误消息丢失。强烈建议希望长时间读取日志文件的客户将日志文件内容复制到其他地方,并立即关闭原始文件。

代码示例

代码示例来源:origin: org.eclipse.core/runtime

/**
 * Private constructor to enforce singleton usage.
 */
private PerformanceStatsProcessor() {
  super("Performance Stats"); //$NON-NLS-1$
  setSystem(true);
  setPriority(DECORATE);
  BundleContext context = PlatformActivator.getContext();
  String filter = '(' + FrameworkLog.SERVICE_PERFORMANCE + '=' + Boolean.TRUE.toString() + ')';
  Collection<ServiceReference<FrameworkLog>> references;
  FrameworkLog perfLog = null;
  try {
    references = context.getServiceReferences(FrameworkLog.class, filter);
    if (references != null && !references.isEmpty()) {
      //just take the first matching service
      perfLog = context.getService(references.iterator().next());
      //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);
  }
  //use the platform log if we couldn't create the performance log
  if (perfLog == null)
    perfLog = InternalPlatform.getDefault().getFrameworkLog();
  log = perfLog;
}

代码示例来源:origin: org.eclipse.ui.views/log

/**
 * Returns whether currently open log is platform log or imported file.
 * @return true if currently open log is platform log, false otherwise
 */
public boolean isPlatformLogOpen() {
  return (fInputFile.equals(Platform.getLogFileLocation().toFile()));
}

代码示例来源:origin: org.eclipse/org.eclipse.pde.runtime

public LogView() {
  fLogs = new ArrayList();
  fInputFile = Platform.getLogFileLocation().toFile();
}

代码示例来源:origin: org.eclipse.ui.views/log

/**
 * Constructor
 */
public LogView() {
  elements = new ArrayList();
  groups = new HashMap();
  batchedEntries = new ArrayList();
  fInputFile = Platform.getLogFileLocation().toFile();
}

代码示例来源:origin: org.eclipse.ui.views/log

public void run() {
    fInputFile = Platform.getLogFileLocation().toFile();
    reloadLog();
  }
};

代码示例来源:origin: org.eclipse.ui.views/log

/**
   * 
   */
  public void setPlatformLog() {
    setLogFile(Platform.getLogFileLocation().toFile());
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.pde.runtime

public void run() {
    fInputFile = Platform.getLogFileLocation().toFile();
    reloadLog();
  }
};

代码示例来源:origin: org.eclipse/org.eclipse.pde.runtime

public void logging(IStatus status, String plugin) {
  if (!fInputFile.equals(Platform.getLogFileLocation().toFile()))
    return;
  if (fFirstEvent) {
    readLogFile();
    asyncRefresh();
    fFirstEvent = false;
  } else {
    pushStatus(status);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

@Override
public void createPageButtons(Composite parent) {
  Button button = createButton(parent, BROWSE_ERROR_LOG_BUTTON,
      WorkbenchMessages.AboutSystemDialog_browseErrorLogName);
  String filename = Platform.getLogFileLocation().toOSString();
  button.setEnabled(new File(filename).exists());
  createButton(parent, COPY_TO_CLIPBOARD_BUTTON,
      WorkbenchMessages.AboutSystemDialog_copyToClipboardName);
}

代码示例来源:origin: org.eclipse/org.eclipse.pde.runtime

private Action createDeleteLogAction() {
  Action action = new Action(PDERuntimeMessages.LogView_delete) { 
    public void run() {
      doDeleteLog();
    }
  };
  action.setToolTipText(PDERuntimeMessages.LogView_delete_tooltip); 
  action.setImageDescriptor(PDERuntimePluginImages.DESC_REMOVE_LOG);
  action.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_REMOVE_LOG_DISABLED);
  action.setEnabled(fInputFile.exists() && fInputFile.equals(Platform.getLogFileLocation().toFile()));
  return action;
}

代码示例来源:origin: io.sarl/io.sarl.eclipse

final String filename = Platform.getLogFileLocation().toOSString();
final File log = new File(filename);
if (!log.exists()) {

代码示例来源:origin: org.eclipse.ui.views/log

private Action createDeleteLogAction() {
  Action action = new Action(Messages.LogView_delete) {
    public void run() {
      doDeleteLog();
    }
  };
  action.setToolTipText(Messages.LogView_delete_tooltip);
  action.setImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_REMOVE_LOG));
  action.setDisabledImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_REMOVE_LOG_DISABLED));
  action.setEnabled(fInputFile.exists() && fInputFile.equals(Platform.getLogFileLocation().toFile()));
  return action;
}

代码示例来源:origin: org.eclipse/org.eclipse.pde.runtime

public void run() {
    if (!fTree.isDisposed()) {
      fTreeViewer.refresh();
      fDeleteLogAction.setEnabled(fInputFile.exists()
          && fInputFile.equals(Platform.getLogFileLocation().toFile()));
      fOpenLogAction.setEnabled(fInputFile.exists());
      fExportAction.setEnabled(fInputFile.exists());
      if (activate && fActivateViewAction.isChecked()) {
        IWorkbenchPage page = PDERuntimePlugin.getActivePage();
        if (page != null)
          page.bringToTop(view);
      }
    }
  }
});

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

public static void openErrorLogBrowser(Shell shell) {
  String filename = Platform.getLogFileLocation().toOSString();

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.core.runtime

/**
 * Private constructor to enforce singleton usage.
 */
private PerformanceStatsProcessor() {
  super("Performance Stats"); //$NON-NLS-1$
  setSystem(true);
  setPriority(DECORATE);
  BundleContext context = PlatformActivator.getContext();
  String filter = '(' + FrameworkLog.SERVICE_PERFORMANCE + '=' + Boolean.TRUE.toString() + ')';
  Collection<ServiceReference<FrameworkLog>> references;
  FrameworkLog perfLog = null;
  try {
    references = context.getServiceReferences(FrameworkLog.class, filter);
    if (references != null && !references.isEmpty()) {
      //just take the first matching service
      perfLog = context.getService(references.iterator().next());
      //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);
  }
  //use the platform log if we couldn't create the performance log
  if (perfLog == null)
    perfLog = InternalPlatform.getDefault().getFrameworkLog();
  log = perfLog;
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.core.runtime

/**
 * Private constructor to enforce singleton usage.
 */
private PerformanceStatsProcessor() {
  super("Performance Stats"); //$NON-NLS-1$
  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);
  }
  //use the platform log if we couldn't create the performance log
  if (perfLog == null)
    perfLog = InternalPlatform.getDefault().getFrameworkLog();
  log = perfLog;
}

代码示例来源:origin: org.eclipse/core-runtime

/**
 * Private constructor to enforce singleton usage.
 */
private PerformanceStatsProcessor() {
  super("Performance Stats"); //$NON-NLS-1$
  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);
  }
  //use the platform log if we couldn't create the performance log
  if (perfLog == null)
    perfLog = InternalPlatform.getDefault().getFrameworkLog();
  log = new PlatformLogWriter(perfLog);
}

代码示例来源:origin: org.eclipse.ui.views/log

public void run() {
    if (!fTree.isDisposed()) {
      TreeViewer viewer = fFilteredTree.getViewer();
      viewer.refresh();
      viewer.expandToLevel(2);
      fDeleteLogAction.setEnabled(fInputFile.exists() && fInputFile.equals(Platform.getLogFileLocation().toFile()));
      fOpenLogAction.setEnabled(fInputFile.exists());
      fExportLogAction.setEnabled(fInputFile.exists());
      fExportLogEntryAction.setEnabled(!viewer.getSelection().isEmpty());
      if (activate && fActivateViewAction.isChecked()) {
        IWorkbenchWindow window = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow();
        if (window != null) {
          IWorkbenchPage page = window.getActivePage();
          if (page != null) {
            page.bringToTop(view);
          }
        }
      }
    }
  }
});

代码示例来源:origin: org.eclipse.ui.views/log

ImportConfigurationLogAction importWorkspaceLogAction = new ImportConfigurationLogAction(Messages.ImportLogAction_reloadWorkspaceLog, Platform.getLogFileLocation().toFile().getAbsolutePath()) {

相关文章