aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/util.ts')
-rw-r--r--editors/code/src/util.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 68c2a94d0..f56c6bada 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -1,22 +1,31 @@
1import * as lc from "vscode-languageclient"; 1import * as lc from "vscode-languageclient";
2import * as vscode from "vscode"; 2import * as vscode from "vscode";
3import { strict as nativeAssert } from "assert";
3 4
4let enabled: boolean = false; 5export function assert(condition: boolean, explanation: string): asserts condition {
6 try {
7 nativeAssert(condition, explanation);
8 } catch (err) {
9 log.error(`Assertion failed:`, explanation);
10 throw err;
11 }
12}
5 13
6export const log = { 14export const log = {
15 enabled: true,
7 debug(message?: any, ...optionalParams: any[]): void { 16 debug(message?: any, ...optionalParams: any[]): void {
8 if (!enabled) return; 17 if (!log.enabled) return;
9 // eslint-disable-next-line no-console 18 // eslint-disable-next-line no-console
10 console.log(message, ...optionalParams); 19 console.log(message, ...optionalParams);
11 }, 20 },
12 error(message?: any, ...optionalParams: any[]): void { 21 error(message?: any, ...optionalParams: any[]): void {
13 if (!enabled) return; 22 if (!log.enabled) return;
14 debugger; 23 debugger;
15 // eslint-disable-next-line no-console 24 // eslint-disable-next-line no-console
16 console.error(message, ...optionalParams); 25 console.error(message, ...optionalParams);
17 }, 26 },
18 setEnabled(yes: boolean): void { 27 setEnabled(yes: boolean): void {
19 enabled = yes; 28 log.enabled = yes;
20 } 29 }
21}; 30};
22 31