Skip to content

Commit 9490704

Browse files
authored
Merge pull request #701 from KxSystems/ee-log
Use vs code logging
2 parents d15a2d2 + cd38279 commit 9490704

File tree

6 files changed

+35
-265
lines changed

6 files changed

+35
-265
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let client: LanguageClient;
125125

126126
export async function activate(context: vscode.ExtensionContext) {
127127
ext.context = context;
128-
ext.outputChannel = vscode.window.createOutputChannel("kdb");
128+
ext.outputChannel = vscode.window.createOutputChannel("kdb", { log: true });
129129
ext.openSslVersion = await checkOpenSslInstalled();
130130

131131
getWorkspaceLabelsConnMap();

src/extensionVariables.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ExtensionContext,
1616
extensions,
1717
languages,
18+
LogOutputChannel,
1819
OutputChannel,
1920
StatusBarItem,
2021
TextEditor,
@@ -49,7 +50,7 @@ export namespace ext {
4950
export const REPL = "REPL";
5051
export let activeTextEditor: TextEditor | undefined;
5152
export let context: ExtensionContext;
52-
export let outputChannel: OutputChannel;
53+
export let outputChannel: LogOutputChannel;
5354
export let consolePanel: OutputChannel;
5455
export let serverProvider: KdbTreeProvider;
5556
export let queryHistoryProvider: QueryHistoryProvider;

src/utils/loggers.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,35 @@ export function kdbOutputLog(
2020
type: string,
2121
supressDialog?: boolean,
2222
): void {
23-
const dateNow = new Date().toLocaleDateString();
24-
const timeNow = new Date().toLocaleTimeString();
25-
ext.outputChannel.appendLine(`[${dateNow} ${timeNow}] [${type}] ${message}`);
23+
/* c8 ignore start */
24+
switch (type) {
25+
case "DEBUG":
26+
ext.outputChannel.debug(message);
27+
break;
28+
case "INFO":
29+
ext.outputChannel.info(message);
30+
break;
31+
case "WARNING":
32+
ext.outputChannel.warn(message);
33+
break;
34+
case "ERROR":
35+
ext.outputChannel.error(message);
36+
break;
37+
default:
38+
ext.outputChannel.trace(message);
39+
break;
40+
}
2641
if (type === "ERROR" && !supressDialog) {
27-
vscode.window.showErrorMessage(
28-
`Error occured, check kdb output channel for details.`,
29-
);
42+
vscode.window
43+
.showErrorMessage(
44+
`Error occured, check kdb output log for details.`,
45+
"Check",
46+
)
47+
.then((res) => {
48+
if (res === "Check") {
49+
ext.outputChannel.show(true);
50+
}
51+
});
52+
/* c8 ignore stop */
3053
}
3154
}

test/suite/commands/dataSourceCommand.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import * as queryUtils from "../../../src/utils/queryUtils";
3636
describe("dataSourceCommand", () => {
3737
let dummyDataSourceFiles: DataSourceFiles;
3838
let _resultsPanel: KdbResultsViewProvider;
39-
ext.outputChannel = vscode.window.createOutputChannel("kdb");
39+
ext.outputChannel = vscode.window.createOutputChannel("kdb", { log: true });
4040
const localConn = new LocalConnection("localhost:5001", "test", []);
4141
const insightsNode = new InsightsNode(
4242
[],
@@ -731,7 +731,7 @@ describe("dataSourceCommand", () => {
731731
writeQueryResultsToConsoleStub: sinon.SinonStub;
732732
let windowMock: sinon.SinonMock;
733733

734-
ext.outputChannel = vscode.window.createOutputChannel("kdb");
734+
ext.outputChannel = vscode.window.createOutputChannel("kdb", { log: true });
735735

736736
beforeEach(() => {
737737
retrieveConnStub = sinon.stub(

test/suite/utils/core.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe("core", () => {
200200

201201
/* eslint-disable @typescript-eslint/no-unused-expressions */
202202
describe("coreLogs", () => {
203-
ext.outputChannel = vscode.window.createOutputChannel("kdb");
203+
ext.outputChannel = vscode.window.createOutputChannel("kdb", { log: true });
204204
let appendLineSpy, showErrorMessageSpy: sinon.SinonSpy;
205205
beforeEach(() => {
206206
appendLineSpy = sinon.spy(

test/suite/utils/loggers.test.ts

Lines changed: 0 additions & 254 deletions
This file was deleted.

0 commit comments

Comments
 (0)