瀏覽代碼

Enables webview logging when debugging

main
Eric Amodio 1 年之前
父節點
當前提交
4ac0554ba0
共有 3 個文件被更改,包括 11 次插入12 次删除
  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 查看文件

@ -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 查看文件

@ -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 查看文件

@ -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: {

Loading…
取消
儲存