Skip to content

Commit f942610

Browse files
authored
[log_ref] support for stack traces and some engineering (ttiimm#18)
Stack traces are not part of a log message format string, so we need to separate them out. This change adds a regex that is run over the body to pull out Python/Java backtraces. If a trace is detected, it is stored in the `trace` field of the `LogDetails` struct. The `body` field will then only contain the message body without the trace. In order to support this, though, the CLI needed to be modified to handle multi-line messages. So, the binary now reads input line-by-line and checks if it matches the log format. If it does, it's considered the start of a new message. If the next line/EOF also matches the format, then we process the message. Otherwise, we add the line to the previous lines to be processed later. Files: * Cargo.toml: Add colored_json to color the output and make it readable. * package.json: Make pnpm version less specific * debugAdapter.ts: Change "--end" to "--count" * lib.rs: Add more LogError variants. Separate a backtrace from the message body. * main.rs: More error checking/reporting. Process input line-by-line and support multi-line messages. Color JSON output to make it easier to read. Command argument changes: - Support multiple source directories - Change --end to --count to avoid issues with end being less than start or having to figure out whether it's inclusive/exclusive.
1 parent 544d7ad commit f942610

22 files changed

+699
-151
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
clap = { version = "4.5.36", features = ["derive"] }
10+
colored_json = "5.0.0"
1011
indicatif = "0.18.0"
1112
itertools = "0.14.0"
1213
regex = "1.11.1"
@@ -19,7 +20,7 @@ tree-sitter-rust-orchard = "0.12.0"
1920
tree-sitter-java = "0.23.5"
2021
tree-sitter-python = "0.25.0"
2122
rayon = "1.11.0"
22-
miette = { version = "7.6.0", features = ["fancy"] }
23+
miette = { version = "7.6.0", features = ["fancy", "serde"] }
2324

2425
[build-dependencies]
2526
cc="*"

editors/code/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"engines": {
1111
"vscode": "^1.83.0",
1212
"node": ">=16.0.0",
13-
"pnpm": "10.8.0"
13+
"pnpm": ">=10.8.0"
1414
},
1515
"categories": [
1616
"Debuggers"

editors/code/src/debugAdapter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ export class DebugSession extends LoggingDebugSession {
270270
const log2srcPath = path.resolve(__dirname, this._binaryPath);
271271
const execFile = require('child_process').execFileSync;
272272
const start = this._line - 1;
273-
const end = this._line;
274273

275274
const editors = this.findEditors();
276275
if (editors.length > 0) {
@@ -280,7 +279,7 @@ export class DebugSession extends LoggingDebugSession {
280279
let l2sArgs = ['-d', this._launchArgs.source,
281280
'--log', this._launchArgs.log,
282281
'--start', start,
283-
'--end', end]
282+
'--count', 1]
284283
if (this._launchArgs.log_format !== undefined && this._launchArgs.log_format !== "") {
285284
l2sArgs.push("-f");
286285
l2sArgs.push(this._launchArgs.log_format);

0 commit comments

Comments
 (0)