Skip to content

Commit c80a51f

Browse files
committed
Log to stderr (vscode output) by default, add option for logfile
1 parent ba18db4 commit c80a51f

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@
131131
"default": "off",
132132
"description": "Traces the communication between VSCode and the languageServerHaskell service."
133133
},
134+
"languageServerHaskell.logFile": {
135+
"scope": "resource",
136+
"type": "string",
137+
"default": "",
138+
"description": "If set, redirects the logs to a file."
139+
},
134140
"languageServerHaskell.enableHIE": {
135141
"scope": "resource",
136142
"type": "boolean",

src/extension.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function activateHieNoCheck(context: ExtensionContext, folder: WorkspaceFolder,
107107
let hieExecutablePath = workspace.getConfiguration('languageServerHaskell', uri).hieExecutablePath;
108108
let customWrapperPath = workspace.getConfiguration('languageServerHaskell', uri).useCustomHieWrapperPath;
109109
const logLevel = workspace.getConfiguration('languageServerHaskell', uri).trace.server;
110+
const logFile = workspace.getConfiguration('languageServerHaskell', uri).logFile;
110111

111112
// Substitute path variables with their corresponding locations.
112113
if (useCustomWrapper) {
@@ -140,17 +141,15 @@ function activateHieNoCheck(context: ExtensionContext, folder: WorkspaceFolder,
140141
const serverPath =
141142
useCustomWrapper || hieExecutablePath ? hieLaunchScript : context.asAbsolutePath(path.join('.', hieLaunchScript));
142143

143-
const tempDir = os.tmpdir();
144-
const runArgs = [];
144+
const runArgs: string[] = [];
145145
let debugArgs: string[] = [];
146146
if (logLevel === 'verbose') {
147-
debugArgs = ['-d', '-l', path.join(tempDir, 'hie.log'), '--vomit'];
147+
debugArgs = ['-d', '--vomit'];
148148
} else if (logLevel === 'messages') {
149-
debugArgs = ['-d', '-l', path.join(tempDir, 'hie.log')];
149+
debugArgs = ['-d'];
150150
}
151-
if (!useCustomWrapper && hieExecutablePath !== '') {
152-
runArgs.unshift('--lsp');
153-
debugArgs.unshift('--lsp');
151+
if (logFile !== '') {
152+
debugArgs = debugArgs.concat(['-l', logFile]);
154153
}
155154

156155
// If the extension is launched in debug mode then the debug server options are used,

0 commit comments

Comments
 (0)