-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Logging setup for lldb-dap extension #146884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ba55b87
Logging setup for lldb-dap extension
award999 6d423f1
Use same timestamp format as `LogOutputChannel`
award999 913edeb
Address review comment
award999 606c335
Some more cleanup
award999 0387965
Fix comment code
award999 c42d534
Extract `logger` as an interface
award999 0dc70d0
Fix issues when bundling
award999 ed7310a
Apply formatting
award999 e709ee1
Use minimal LogOutputChannel approach instead
award999 ca7fd10
Rename "verboseLogging" setting to "captureSessionLogs"
award999 d0b9ec7
Deprecate `lldb-dap.log-path` setting in favour of `lldb-dap.logFolder`
award999 968b582
Update lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
award999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import * as path from "path"; | ||
| import * as vscode from "vscode"; | ||
|
|
||
| /** | ||
| * Formats the given date as a string in the form "YYYYMMddTHHMMSS". | ||
| * | ||
| * @param date The date to format as a string. | ||
| * @returns The formatted date. | ||
| */ | ||
| function formatDate(date: Date): string { | ||
| const year = date.getFullYear().toString().padStart(4, "0"); | ||
| const month = (date.getMonth() + 1).toString().padStart(2, "0"); | ||
| const day = date.getDate().toString().padStart(2, "0"); | ||
| const hour = date.getHours().toString().padStart(2, "0"); | ||
| const minute = date.getMinutes().toString().padStart(2, "0"); | ||
| const seconds = date.getSeconds().toString().padStart(2, "0"); | ||
| return `${year}${month}${day}T${hour}${minute}${seconds}`; | ||
| } | ||
|
|
||
| export enum LogType { | ||
| DEBUG_SESSION, | ||
| } | ||
|
|
||
| export class LogFilePathProvider { | ||
| private logFolder: string = ""; | ||
|
|
||
| constructor( | ||
| private context: vscode.ExtensionContext, | ||
| private logger: vscode.LogOutputChannel, | ||
| ) { | ||
| this.updateLogFolder(); | ||
| context.subscriptions.push( | ||
| vscode.workspace.onDidChangeConfiguration(e => { | ||
| if ( | ||
| e.affectsConfiguration("lldb-dap.logFolder") | ||
| ) { | ||
| this.updateLogFolder(); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
|
|
||
| get(type: LogType): string { | ||
| const logFolder = this.logFolder || this.context.logUri.fsPath; | ||
| switch(type) { | ||
| case LogType.DEBUG_SESSION: | ||
| return path.join(logFolder, `lldb-dap-session-${formatDate(new Date())}.log`); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| private updateLogFolder() { | ||
| const config = vscode.workspace.getConfiguration("lldb-dap"); | ||
| let logFolder = | ||
| config.get<string>("logFolder") || this.context.logUri.fsPath; | ||
| vscode.workspace.fs | ||
| .createDirectory(vscode.Uri.file(logFolder)) | ||
| .then(undefined, (error) => { | ||
| this.logger.error(`Failed to create log folder ${logFolder}: ${error}`); | ||
| logFolder = this.context.logUri.fsPath; | ||
| }) | ||
| .then(() => { | ||
| this.logFolder = logFolder; | ||
| this.logger.info(`Persisting lldb-dap logs to ${logFolder}`); | ||
| }); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.