Log file settings for Eclipse client
This commit is contained in:
@@ -16,12 +16,9 @@ import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.springframework.tooling.ls.eclipse.commons.JRE;
|
||||
import org.springframework.tooling.ls.eclipse.commons.JRE.MissingJDKException;
|
||||
import org.springframework.tooling.ls.eclipse.commons.LanguageServerCommonsActivator;
|
||||
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
|
||||
import org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
@@ -51,14 +48,6 @@ public class SpringBootLanguageServer extends STS4LanguageServerProcessStreamCon
|
||||
args.add("-XX:+HeapDumpOnOutOfMemoryError");
|
||||
args.add("-XX:TieredStopAtLevel=1");
|
||||
|
||||
if (!LanguageServerCommonsActivator.getInstance().getPreferenceStore().getBoolean(LanguageServerConsolePreferenceConstants.PREF_BOOT_JAVA_CONSOLE_ENABLED)) {
|
||||
IPath logFile = BootLanguageServerPlugin.getDefault().getStateLocation().addTrailingSeparator().append("boot-ls.log");
|
||||
args.add("-Dsts.log.file=" + logFile.toFile().getPath());
|
||||
}
|
||||
|
||||
IPath fatalErrorFile = BootLanguageServerPlugin.getDefault().getStateLocation().addTrailingSeparator().append("fatal-eror-boot-ls.log");
|
||||
args.add("-XX:ErrorFile=" + fatalErrorFile.toFile().getPath());
|
||||
|
||||
addCustomJVMArgs(args);
|
||||
|
||||
return args;
|
||||
|
||||
@@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.8.0",
|
||||
org.eclipse.ui.genericeditor,
|
||||
org.eclipse.ui.editors,
|
||||
org.springsource.ide.eclipse.commons.core,
|
||||
org.eclipse.e4.ui.css.swt.theme
|
||||
org.eclipse.e4.ui.css.swt.theme,
|
||||
org.eclipse.swt
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.springframework.tooling.ls.eclipse.commons,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -25,11 +25,13 @@ import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.springframework.tooling.ls.eclipse.commons.console.ConsoleUtil.Console;
|
||||
import org.springframework.tooling.ls.eclipse.commons.console.LanguageServerConsoles;
|
||||
import org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.ServerInfo;
|
||||
import org.springframework.tooling.ls.eclipse.commons.preferences.LsPreferencesUtil;
|
||||
import org.springsource.ide.eclipse.commons.core.util.IOUtil;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
@@ -90,7 +92,7 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
|
||||
command.add(runtime.getJavaExecutable());
|
||||
command.add("-cp");
|
||||
|
||||
File bundleFile = FileLocator.getBundleFile(bundle);
|
||||
File bundleFile = FileLocator.getBundleFileLocation(bundle).orElse(null);
|
||||
|
||||
File bundleRoot = bundleFile.getAbsoluteFile();
|
||||
Path languageServerRoot = bundleRoot.toPath().resolve(lsFolder);
|
||||
@@ -122,6 +124,17 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
|
||||
command.add("-Dspring.config.location=file:" + languageServerRoot.resolve("BOOT-INF/classes").resolve(configFileName).toFile());
|
||||
}
|
||||
|
||||
LsPreferencesUtil.getServerInfo(getPluginId()).ifPresent(info -> {
|
||||
IPreferenceStore preferenceStore = LanguageServerCommonsActivator.getInstance().getPreferenceStore();
|
||||
if (!preferenceStore.getBoolean(info.preferenceKeyConsoleLog)) {
|
||||
String pathStr = preferenceStore.getString(info.preferenceKeyFileLog);
|
||||
if (pathStr != null && !pathStr.isBlank()) {
|
||||
command.add("-Dsts.log.file=" + pathStr);
|
||||
}
|
||||
}
|
||||
command.add("-XX:ErrorFile=" + Platform.getStateLocation(bundle).append("fatal-error-" + info.label.replaceAll("\\s+", "-").toLowerCase() + "_" + System.currentTimeMillis()));
|
||||
});
|
||||
|
||||
command.add(mainClass);
|
||||
|
||||
command.add("--languageserver.hover-timeout=225");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -47,7 +47,7 @@ public class LanguageServerConsoles {
|
||||
}
|
||||
|
||||
private static boolean isConsoleEnabled(ServerInfo server) {
|
||||
return LanguageServerCommonsActivator.getInstance().getPreferenceStore().getBoolean(server.preferenceKey);
|
||||
return LanguageServerCommonsActivator.getInstance().getPreferenceStore().getBoolean(server.preferenceKeyConsoleLog);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -15,14 +15,18 @@ public class LanguageServerConsolePreferenceConstants {
|
||||
public static final boolean ENABLE_BY_DEFAULT = false;
|
||||
|
||||
public static final String PREF_BOOT_JAVA_CONSOLE_ENABLED = "boot-java.console.enabled";
|
||||
public static final String PREF_BOOT_JAVA_LOG_FILE = "boot-java.log.file";
|
||||
public static final String PREF_CONCOURSE_CONSOLE_ENABLED = "concourse.console.enabled";
|
||||
public static final String PREF_CONCOURSE_FILE_LOG = "concourse.file.log";
|
||||
public static final String PREF_CLOUDFOUNDRY_CONSOLE_ENABLED = "cloudfoundry.console.enabled";
|
||||
public static final String PREF_CLOUDFOUNDRY_LOG_FILE = "cloudfoundry.log.file";
|
||||
public static final String PREF_BOSH_CONSOLE_ENABLED = "bosh.console.enabled";
|
||||
public static final String PREF_BOSH_LOG_FILE = "bosh.log.file";
|
||||
|
||||
public static final ServerInfo SPRING_BOOT_SERVER = new ServerInfo(PREF_BOOT_JAVA_CONSOLE_ENABLED, "Spring Boot", "org.springframework.tooling.boot.ls");
|
||||
public static final ServerInfo CLOUDFOUNDRY_SERVER = new ServerInfo(PREF_CLOUDFOUNDRY_CONSOLE_ENABLED, "Cloudfoundry", "org.springframework.tooling.cloudfoundry.manifest.ls");
|
||||
public static final ServerInfo CONCOURSE_SERVER = new ServerInfo(PREF_CONCOURSE_CONSOLE_ENABLED, "Concourse", "org.springframework.tooling.concourse.ls");
|
||||
public static final ServerInfo BOSH_SERVER = new ServerInfo(PREF_BOSH_CONSOLE_ENABLED, "Bosh", "org.springframework.tooling.bosh.ls");
|
||||
public static final ServerInfo SPRING_BOOT_SERVER = new ServerInfo(PREF_BOOT_JAVA_CONSOLE_ENABLED, PREF_BOOT_JAVA_LOG_FILE, "Spring Boot", "org.springframework.tooling.boot.ls");
|
||||
public static final ServerInfo CLOUDFOUNDRY_SERVER = new ServerInfo(PREF_CLOUDFOUNDRY_CONSOLE_ENABLED, PREF_CLOUDFOUNDRY_LOG_FILE, "Cloudfoundry", "org.springframework.tooling.cloudfoundry.manifest.ls");
|
||||
public static final ServerInfo CONCOURSE_SERVER = new ServerInfo(PREF_CONCOURSE_CONSOLE_ENABLED, PREF_CONCOURSE_FILE_LOG, "Concourse", "org.springframework.tooling.concourse.ls");
|
||||
public static final ServerInfo BOSH_SERVER = new ServerInfo(PREF_BOSH_CONSOLE_ENABLED, PREF_BOSH_LOG_FILE, "Bosh", "org.springframework.tooling.bosh.ls");
|
||||
|
||||
public static final ServerInfo[] ALL_SERVERS = {
|
||||
SPRING_BOOT_SERVER,
|
||||
@@ -32,18 +36,19 @@ public class LanguageServerConsolePreferenceConstants {
|
||||
};
|
||||
|
||||
public static class ServerInfo {
|
||||
public final String preferenceKey;
|
||||
public final String preferenceKeyConsoleLog;
|
||||
public final String preferenceKeyFileLog;
|
||||
public final String label;
|
||||
public final String bundleId;
|
||||
public ServerInfo(String preferenceKey, String label, String bundleId) {
|
||||
super();
|
||||
this.preferenceKey = preferenceKey;
|
||||
public ServerInfo(String preferenceKeyConsoleLog, String preferenceKeyFileLog, String label, String bundleId) {
|
||||
this.preferenceKeyConsoleLog = preferenceKeyConsoleLog;
|
||||
this.preferenceKeyFileLog = preferenceKeyFileLog;
|
||||
this.label = label;
|
||||
this.bundleId = bundleId;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerInfo [preferenceKey=" + preferenceKey + ", label=" + label + ", bundleId=" + bundleId + "]";
|
||||
return "ServerInfo [preferenceKeyConsoleLog=" + preferenceKeyConsoleLog + ", label=" + label + ", bundleId=" + bundleId + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -10,10 +10,20 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.ls.eclipse.commons.preferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.FileFieldEditor;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.springframework.tooling.ls.eclipse.commons.LanguageServerCommonsActivator;
|
||||
@@ -27,17 +37,87 @@ public class LanguageServerPreferencesPage extends FieldEditorPreferencePage imp
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
setDescription("Enablement of STS Language Server Debug Consoles. "
|
||||
+ "Changes only take effect the next time a Language Server is started.");
|
||||
setDescription("Log settings for STS Language Servers. "
|
||||
+ "Changes only take effect the next time a Language Server is started.\n"
|
||||
+ "\n"
|
||||
+ "Note: Enabling logging to console disables logging to file!\n");
|
||||
setPreferenceStore(getPrefsStoreFromPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
Composite parent = getFieldEditorParent();
|
||||
ServerInfo[] installedServers = LsPreferencesUtil.getInstalledLs();
|
||||
Composite fieldEditorParent = getFieldEditorParent();
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 1;
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
fieldEditorParent.setLayout(layout);
|
||||
for (ServerInfo s : installedServers) {
|
||||
addField(new BooleanFieldEditor(s.preferenceKey, s.label, parent));
|
||||
Group group = new Group(fieldEditorParent, SWT.None);
|
||||
group.setText(s.label);
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
layout = new GridLayout();
|
||||
layout.numColumns = 1;
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
group.setLayout(layout);
|
||||
|
||||
Composite c1 = new Composite(group, SWT.NONE);
|
||||
c1.setLayout(new GridLayout());
|
||||
c1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
addField(new FileFieldEditor(s.preferenceKeyFileLog, "Logging to File", true, c1) {
|
||||
|
||||
@Override
|
||||
protected boolean checkState() {
|
||||
|
||||
String msg = null;
|
||||
|
||||
String path = getTextControl().getText();
|
||||
if (path != null) {
|
||||
path = path.trim();
|
||||
} else {
|
||||
path = "";//$NON-NLS-1$
|
||||
}
|
||||
if (path.isEmpty()) {
|
||||
if (!isEmptyStringAllowed()) {
|
||||
msg = getErrorMessage();
|
||||
}
|
||||
} else {
|
||||
Path p = new File(path).toPath();
|
||||
if (!Files.isDirectory(p) && !Files.isSymbolicLink(p)) {
|
||||
if (!p.isAbsolute()) {
|
||||
msg = JFaceResources
|
||||
.getString("FileFieldEditor.errorMessage2");//$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
msg = getErrorMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (msg != null) { // error
|
||||
showErrorMessage(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(doCheckState()) { // OK!
|
||||
clearErrorMessage();
|
||||
return true;
|
||||
}
|
||||
msg = getErrorMessage(); // subclass might have changed it in the #doCheckState()
|
||||
if (msg != null) {
|
||||
showErrorMessage(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Composite c2 = new Composite(group, SWT.NONE);
|
||||
c2.setLayout(new GridLayout());
|
||||
c2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
addField(new BooleanFieldEditor(s.preferenceKeyConsoleLog, "Logging to Console", c2));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2019, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -14,6 +14,7 @@ import static org.springframework.tooling.ls.eclipse.commons.preferences.Languag
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.osgi.framework.Bundle;
|
||||
@@ -33,4 +34,13 @@ public class LsPreferencesUtil {
|
||||
return serverInfos.toArray(new ServerInfo[serverInfos.size()]);
|
||||
}
|
||||
|
||||
public static Optional<ServerInfo> getServerInfo(String bundleId) {
|
||||
for (ServerInfo info : ALL_SERVERS) {
|
||||
if (info.bundleId.equals(bundleId)) {
|
||||
return Optional.of(info);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -12,8 +12,11 @@ package org.springframework.tooling.ls.eclipse.commons.preferences;
|
||||
|
||||
import static org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.ENABLE_BY_DEFAULT;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.ServerInfo;
|
||||
|
||||
public class PrefsInitializer extends AbstractPreferenceInitializer {
|
||||
@@ -22,7 +25,14 @@ public class PrefsInitializer extends AbstractPreferenceInitializer {
|
||||
IPreferenceStore store = LanguageServerPreferencesPage.getPrefsStoreFromPlugin();
|
||||
ServerInfo[] installedServers = LsPreferencesUtil.getInstalledLs();
|
||||
for (ServerInfo s : installedServers) {
|
||||
store.setDefault(s.preferenceKey, ENABLE_BY_DEFAULT);
|
||||
store.setDefault(s.preferenceKeyConsoleLog, ENABLE_BY_DEFAULT);
|
||||
Bundle bundle = Platform.getBundle(s.bundleId);
|
||||
if (bundle != null) {
|
||||
IPath stateLocation = Platform.getStateLocation(bundle);
|
||||
if (stateLocation != null) {
|
||||
store.setDefault(s.preferenceKeyFileLog, stateLocation.append(s.label.toLowerCase().replaceAll("\\s+", "-") + ".log").toFile().getAbsoluteFile().getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
store.setDefault(PreferenceConstants.HIGHLIGHT_CODELENS_PREFS, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user