Kaynağa Gözat

Enables webview logging when debugging

main
Eric Amodio 1 yıl önce
ebeveyn
işleme
4ac0554ba0
3 değiştirilmiş dosya ile 11 ekleme ve 12 silme
  1. +4
    -4
      src/logger.ts
  2. +3
    -7
      src/webviews/apps/shared/appBase.ts
  3. +4
    -1
      webpack.config.js

+ 4
- 4
src/logger.ts Dosyayı Görüntüle

@ -20,8 +20,8 @@ export interface LogChannelProvider {
export interface LogChannel {
readonly name: string;
appendLine(value: string): void;
dispose(): void;
show(preserveFocus?: boolean): void;
dispose?(): void;
show?(preserveFocus?: boolean): void;
}
export const Logger = new (class Logger {
@ -54,7 +54,7 @@ export const Logger = new (class Logger {
this.level = toOrderedLevel(this._logLevel);
if (value === LogLevel.Off) {
this.output?.dispose();
this.output?.dispose?.();
this.output = undefined;
} else {
this.output = this.output ?? this.provider!.createChannel(this.provider!.name);
@ -170,7 +170,7 @@ export const Logger = new (class Logger {
}
showOutputChannel(preserveFocus?: boolean): void {
this.output?.show(preserveFocus);
this.output?.show?.(preserveFocus);
}
toLoggable(o: any, sanitize?: ((key: string, value: any) => any) | undefined) {

+ 3
- 7
src/webviews/apps/shared/appBase.ts Dosyayı Görüntüle

@ -15,6 +15,8 @@ import type { Disposable } from './events';
import type { ThemeChangeEvent } from './theme';
import { initializeAndWatchThemeColors, onDidChangeTheme } from './theme';
declare const DEBUG: boolean;
interface VsCodeApi {
postMessage(msg: unknown): void;
setState(state: unknown): void;
@ -53,16 +55,10 @@ export abstract class App {
appendLine: function (value: string) {
console.log(`[${name}] ${value}`);
},
dispose: function () {
// noop
},
show: function (_preserveFocus?: boolean) {
// noop
},
};
},
},
LogLevel.Debug,
DEBUG ? LogLevel.Debug : LogLevel.Off,
);
this.log(`ctor()`);

+ 4
- 1
webpack.config.js Dosyayı Görüntüle

@ -19,7 +19,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const { validate } = require('schema-utils');
const TerserPlugin = require('terser-webpack-plugin');
const { WebpackError, optimize, webpack } = require('webpack');
const { DefinePlugin, optimize, WebpackError } = require('webpack');
const WebpackRequireFromPlugin = require('webpack-require-from');
module.exports =
@ -285,6 +285,9 @@ function getWebviewsConfig(mode, env) {
}
: undefined,
),
new DefinePlugin({
DEBUG: mode === 'development',
}),
new ForkTsCheckerPlugin({
async: false,
eslint: {

Yükleniyor…
İptal
Kaydet