Skip to content

Commit e709ee1

Browse files
committed
Use minimal LogOutputChannel approach instead
1 parent ed7310a commit e709ee1

File tree

8 files changed

+26
-871
lines changed

8 files changed

+26
-871
lines changed

lldb/tools/lldb-dap/package-lock.json

Lines changed: 7 additions & 720 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lldb/tools/lldb-dap/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,17 @@
3232
"@types/vscode": "1.75.0",
3333
"@vscode/debugprotocol": "^1.68.0",
3434
"@vscode/vsce": "^3.2.2",
35-
"esbuild": "^0.25.8",
3635
"prettier": "^3.4.2",
3736
"prettier-plugin-curly": "^0.3.1",
38-
"typescript": "^5.7.3",
39-
"winston": "^3.17.0",
40-
"winston-transport": "^4.9.0"
37+
"typescript": "^5.7.3"
4138
},
4239
"activationEvents": [
4340
"onDebug",
4441
"onUri"
4542
],
4643
"main": "./out/extension",
4744
"scripts": {
48-
"vscode:prepublish": "esbuild src-ts/extension.ts --bundle --platform=node --external:vscode --minify --outfile=out/extension.js",
45+
"vscode:prepublish": "tsc -p ./",
4946
"watch": "tsc -watch -p ./",
5047
"format": "npx prettier './src-ts/' --write",
5148
"package": "vsce package --out ./out/lldb-dap.vsix",

lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as child_process from "child_process";
55
import * as fs from "node:fs/promises";
66
import { ConfigureButton, OpenSettingsButton } from "./ui/show-error-message";
77
import { ErrorWithNotification } from "./ui/error-with-notification";
8-
import { LogFilePathProvider, Logger } from "./logger";
8+
import { LogFilePathProvider } from "./types";
99

1010
const exec = util.promisify(child_process.execFile);
1111

@@ -177,15 +177,15 @@ function formatDate(date: Date): string {
177177
* Creates a new {@link vscode.DebugAdapterExecutable} based on the provided workspace folder and
178178
* debug configuration. Assumes that the given debug configuration is for a local launch of lldb-dap.
179179
*
180-
* @param logger The {@link Logger} to get default session log location
180+
* @param logger The {@link vscode.LogOutputChannel} to log setup diagnostics
181181
* @param logFilePath The {@link LogFilePathProvider} for determining where to put session logs
182182
* @param workspaceFolder The {@link vscode.WorkspaceFolder} that the debug session will be launched within
183183
* @param configuration The {@link vscode.DebugConfiguration} that will be launched
184184
* @throws An {@link ErrorWithNotification} if something went wrong
185185
* @returns The {@link vscode.DebugAdapterExecutable} that can be used to launch lldb-dap
186186
*/
187187
export async function createDebugAdapterExecutable(
188-
logger: Logger,
188+
logger: vscode.LogOutputChannel,
189189
logFilePath: LogFilePathProvider,
190190
workspaceFolder: vscode.WorkspaceFolder | undefined,
191191
configuration: vscode.DebugConfiguration,
@@ -233,7 +233,7 @@ export class LLDBDapDescriptorFactory
233233
implements vscode.DebugAdapterDescriptorFactory
234234
{
235235
constructor(
236-
private readonly logger: Logger,
236+
private readonly logger: vscode.LogOutputChannel,
237237
private logFilePath: LogFilePathProvider,
238238
) {}
239239

@@ -242,7 +242,7 @@ export class LLDBDapDescriptorFactory
242242
executable: vscode.DebugAdapterExecutable | undefined,
243243
): Promise<vscode.DebugAdapterDescriptor | undefined> {
244244
this.logger.info(`Creating debug adapter for session "${session.name}"`);
245-
this.logger.debug(
245+
this.logger.info(
246246
`Session "${session.name}" debug configuration:\n` +
247247
JSON.stringify(session.configuration, undefined, 2),
248248
);

lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { LLDBDapServer } from "./lldb-dap-server";
55
import { createDebugAdapterExecutable } from "./debug-adapter-factory";
66
import { ConfigureButton, showErrorMessage } from "./ui/show-error-message";
77
import { ErrorWithNotification } from "./ui/error-with-notification";
8-
import { LogFilePathProvider, Logger } from "./logger";
8+
import { LogFilePathProvider } from "./types";
99

1010
const exec = util.promisify(child_process.execFile);
1111

@@ -74,7 +74,7 @@ export class LLDBDapConfigurationProvider
7474
{
7575
constructor(
7676
private readonly server: LLDBDapServer,
77-
private readonly logger: Logger,
77+
private readonly logger: vscode.LogOutputChannel,
7878
private readonly logFilePath: LogFilePathProvider,
7979
) {}
8080

@@ -198,7 +198,7 @@ export class LLDBDapConfigurationProvider
198198
}
199199
}
200200

201-
this.logger.debug(
201+
this.logger.info(
202202
"Resolved debug configuration:\n" +
203203
JSON.stringify(debugConfiguration, undefined, 2),
204204
);

lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { DebugProtocol } from "@vscode/debugprotocol";
22
import * as vscode from "vscode";
3-
import { Logger } from "./logger";
43

54
/** A helper type for mapping event types to their corresponding data type. */
65
// prettier-ignore
@@ -49,7 +48,7 @@ export class DebugSessionTracker
4948
onDidChangeModules: vscode.Event<vscode.DebugSession | undefined> =
5049
this.modulesChanged.event;
5150

52-
constructor(private logger: Logger) {
51+
constructor(private logger: vscode.LogOutputChannel) {
5352
this.onDidChangeModules(this.moduleChangedListener, this);
5453
vscode.debug.onDidChangeActiveDebugSession((session) =>
5554
this.modulesChanged.fire(session),

lldb/tools/lldb-dap/src-ts/extension.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import {
1111
ModulesDataProvider,
1212
ModuleProperty,
1313
} from "./ui/modules-data-provider";
14-
import { LLDBDAPLogger, LogFilePathProvider } from "./logger";
14+
import { LogFilePathProvider } from "./types";
1515

1616
/**
1717
* This class represents the extension and manages its life cycle. Other extensions
1818
* using it as as library should use this class as the main entry point.
1919
*/
2020
export class LLDBDapExtension extends DisposableContext {
2121
constructor(
22-
logger: LLDBDAPLogger,
22+
logger: vscode.LogOutputChannel,
2323
logFilePath: LogFilePathProvider,
2424
outputChannel: vscode.OutputChannel,
2525
) {
@@ -63,17 +63,12 @@ export class LLDBDapExtension extends DisposableContext {
6363
* This is the entry point when initialized by VS Code.
6464
*/
6565
export async function activate(context: vscode.ExtensionContext) {
66-
await vscode.workspace.fs.createDirectory(context.logUri);
67-
const outputChannel = vscode.window.createOutputChannel("LLDB-DAP");
68-
const logFilePath: LogFilePathProvider = (name) =>
66+
const outputChannel = vscode.window.createOutputChannel("LLDB-DAP", { log: true });
67+
const logFilePath: LogFilePathProvider = (name: string) =>
6968
path.join(context.logUri.fsPath, name);
70-
const logger = new LLDBDAPLogger(
71-
logFilePath("lldb-dap-extension.log"),
72-
outputChannel,
73-
);
74-
logger.info("LLDB-Dap extension activating...");
69+
outputChannel.info("LLDB-Dap extension activating...");
7570
context.subscriptions.push(
76-
new LLDBDapExtension(logger, logFilePath, outputChannel),
71+
new LLDBDapExtension(outputChannel, logFilePath, outputChannel),
7772
);
78-
logger.info("LLDB-Dap extension activated");
73+
outputChannel.info("LLDB-Dap extension activated");
7974
}

lldb/tools/lldb-dap/src-ts/logger.ts

Lines changed: 0 additions & 124 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type LogFilePathProvider = (name: string) => string;

0 commit comments

Comments
 (0)