From ea509702b6ed88951a1b7b109b5dc597ee81112d Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sat, 2 Oct 2021 16:53:46 +0200 Subject: feat(web): add client-side logging support Also modified langauge-web/src/main/js/xtext/ServiceBuilder.js to make sure the new logger is used as soon as xtext is initialized. --- language-web/src/main/js/editor/EditorStore.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'language-web/src/main/js/editor/EditorStore.ts') diff --git a/language-web/src/main/js/editor/EditorStore.ts b/language-web/src/main/js/editor/EditorStore.ts index 1ac2e79f..8b9432dd 100644 --- a/language-web/src/main/js/editor/EditorStore.ts +++ b/language-web/src/main/js/editor/EditorStore.ts @@ -8,8 +8,11 @@ import { import type { IXtextOptions, IXtextServices } from 'xtext/xtext-codemirror'; import type { IEditorChunk } from './editor'; +import { getLogger } from '../logging'; import type { ThemeStore } from '../theme/ThemeStore'; +const log = getLogger('EditorStore'); + const xtextLang = 'problem'; const xtextOptions: IXtextOptions = { @@ -52,12 +55,20 @@ export class EditorStore { xtextServices: observable.ref, initialSelection: false, }); + this.loadChunk(); + } + + private loadChunk(): void { + const loadingStartMillis = Date.now(); + log.info('Requesting editor chunk'); import('./editor').then(({ editorChunk }) => { runInAction(() => { this.chunk = editorChunk; }); + const loadingDurationMillis = Date.now() - loadingStartMillis; + log.info('Loaded editor chunk in', loadingDurationMillis, 'ms'); }).catch((error) => { - console.warn('Error while loading editor', error); + log.error('Error while loading editor', error); }); } -- cgit v1.2.3-70-g09d2