Do not auto-redirect language server logs to file
See: https://github.com/spring-projects/sts4/issues/328
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
package org.springframework.ide.vscode.commons.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
@@ -20,20 +21,30 @@ public class LogRedirect {
|
||||
public static void bootRedirectToFile(String name) throws IOException {
|
||||
String logfilePath = System.getProperty("sts.log.file");
|
||||
if (StringUtil.hasText(logfilePath)) {
|
||||
File logfile = new File(logfilePath);
|
||||
System.err.println("Redirecting log output to: "+logfile);
|
||||
PrintStream logFile = new PrintStream(new FileOutputStream(logfile, false));
|
||||
PrintStream logFile = logFileStream(logfilePath);
|
||||
System.setErr(logFile);
|
||||
System.setOut(logFile); //Spring boot actually logs on sysout instead of syserr.
|
||||
}
|
||||
}
|
||||
|
||||
private static PrintStream logFileStream(String logfilePath) throws FileNotFoundException {
|
||||
if (logfilePath.equals("/dev/null")) {
|
||||
System.err.println("Disabling server log output. No more output will be sent after this.");
|
||||
//redirect to a file called "/dev/null" works fine in Unix, but we also want this
|
||||
// to work on Mac and Windows. So we create our own '/dev/null' stream
|
||||
return new PrintStream(new NullOutputStream());
|
||||
} else {
|
||||
System.err.println("Redirecting log output to: "+logfilePath);
|
||||
File logfile = new File(logfilePath);
|
||||
PrintStream logFile = new PrintStream(new FileOutputStream(logfile, false));
|
||||
return logFile;
|
||||
}
|
||||
}
|
||||
|
||||
public static void redirectToFile(String name) throws IOException {
|
||||
String logfilePath = System.getProperty("sts.log.file");
|
||||
if (StringUtil.hasText(logfilePath)) {
|
||||
File logfile = new File(logfilePath);
|
||||
System.err.println("Redirecting log output to: "+logfile);
|
||||
PrintStream logFile = new PrintStream(new FileOutputStream(logfile, false));
|
||||
PrintStream logFile = logFileStream(logfilePath);
|
||||
System.setErr(logFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* An output stream that behaves just like "/dev/null" on Unix. I.e. any output
|
||||
* written to it is silently discarded.
|
||||
*/
|
||||
public class NullOutputStream extends OutputStream {
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -146,14 +146,14 @@ export function activate(options: ActivatorOptions, context: VSCode.ExtensionCon
|
||||
let processLaunchoptions = {
|
||||
cwd: VSCode.workspace.rootPath
|
||||
};
|
||||
let logfile = Path.join(tmpdir(), options.extensionId + '-' + Date.now()+'.log');
|
||||
let logfile : string = options.workspaceOptions.get("logfile") || "/dev/null";
|
||||
//The logfile = '/dev/null' is handled specifically by the language server process so it works on all OSs.
|
||||
log('Redirecting server logs to ' + logfile);
|
||||
const args = [
|
||||
'-Dspring.lsp.client-port='+port,
|
||||
'-Dserver.port=' + port,
|
||||
'-Dsts.lsp.client=vscode',
|
||||
'-Dsts.log.file=' + logfile, //old style log redirect
|
||||
'-Dlogging.file=' + logfile, // spring boot log redirect
|
||||
'-Dsts.log.file=' + logfile,
|
||||
'-XX:TieredStopAtLevel=1'
|
||||
];
|
||||
if (options.checkjvm) {
|
||||
|
||||
@@ -64,6 +64,13 @@
|
||||
"type": "object",
|
||||
"title": "Bosh CLI Configuration",
|
||||
"properties": {
|
||||
"bosh.ls.logfile": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "The path of a file to write language server logs. If not set or null, then logs are discarded."
|
||||
},
|
||||
"bosh.ls.java.heap": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -32,6 +32,13 @@
|
||||
"type": "object",
|
||||
"title": "Concourse Language Server Options",
|
||||
"properties": {
|
||||
"concourse.ls.logfile": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "The path of a file to write language server logs. If not set or null, then logs are discarded."
|
||||
},
|
||||
"concourse.ls.java.heap": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -49,6 +49,13 @@
|
||||
"configuration": {
|
||||
"title": "Cloudfoundry Manifest Language Server Configuration",
|
||||
"properties": {
|
||||
"cloudfoundry-manifest.ls.logfile": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "The path of a file to write language server logs. If not set or null, then logs are discarded."
|
||||
},
|
||||
"cloudfoundry-manifest.ls.java.heap": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "vscode-spring-boot",
|
||||
"version": "1.8.0",
|
||||
"version": "1.10.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@pivotal-tools/commons-vscode": {
|
||||
"version": "file:../commons-vscode/pivotal-tools-commons-vscode-0.2.2.tgz",
|
||||
"integrity": "sha512-wpuWx/wm1LYQ6vF2lfiLzETLzPFlNiUtzqoQd8eMhd5MQLeqJIAB9P2s3TggdD6bdpP+z2cknaAr5bpnTfMd2Q==",
|
||||
"integrity": "sha512-i/QoMGh2yISKeZp0/8bEXON+z5sf6eNngHSXdS+DxpXksXNNyXn8gwg1byVdBl0x5nN16BKGqH+/obQH+Fj9Pg==",
|
||||
"requires": {
|
||||
"@pivotal-tools/jvm-launch-utils": "0.0.12",
|
||||
"deep-equal": "^1.0.1",
|
||||
|
||||
@@ -133,10 +133,17 @@
|
||||
},
|
||||
"description": "Array of jmx urls pointing to remote spring boot applications to poll for live hover information. A typical url looks something like this: `service:jmx:rmi://localhost:9111/jndi/rmi://localhost:9111/jmxrmi`"
|
||||
},
|
||||
"spring-boot.ls.logfile": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "The path of a file to write language server logs. If not set or null, then logs are discarded."
|
||||
},
|
||||
"spring-boot.ls.java.home": {
|
||||
"type": [
|
||||
"string",
|
||||
null
|
||||
"null"
|
||||
],
|
||||
"default": null,
|
||||
"description": "Override JAVA_HOME used for launching the spring-boot-language-server JVM process."
|
||||
@@ -144,7 +151,7 @@
|
||||
"spring-boot.ls.java.heap": {
|
||||
"type": [
|
||||
"string",
|
||||
null
|
||||
"null"
|
||||
],
|
||||
"default": null,
|
||||
"description": "Max JVM heap value, passed via -Xmx argument when launching spring-boot-language-server JVM process."
|
||||
|
||||
Reference in New Issue
Block a user