Skip to content

Commit e741072

Browse files
committed
feat: Also log Xdebug/DBGp packets that will ease adapter debugging. (#586)
1 parent c9766a6 commit e741072

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
99
### Added
1010

1111
- Option to start PHP built-in web server without router script.
12+
- Extended logging with DBGp packets.
1213

1314
### Changed
1415

src/dbgp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export class DbgpConnection extends EventEmitter {
8383
},
8484
},
8585
})
86+
this.emit('log', `-> ${xml.replace(/[\0\n]/g, '')}`)
8687
const document = parser.parseFromString(xml, 'application/xml')
8788
this.emit('message', document)
8889
// reset buffer
@@ -107,6 +108,7 @@ export class DbgpConnection extends EventEmitter {
107108
public write(command: Buffer): Promise<void> {
108109
return new Promise<void>((resolve, reject) => {
109110
if (this._socket.writable) {
111+
this.emit('log', `<- ${command.toString().replace(/[\0\n]/g, '')}`)
110112
this._socket.write(command, () => {
111113
resolve()
112114
})

src/phpDebug.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ class PhpDebugSession extends vscode.DebugSession {
295295
})
296296
connection.on('error', disposeConnection)
297297
connection.on('close', disposeConnection)
298+
connection.on('log', (text: string) => {
299+
if (this._args && this._args.log) {
300+
const log = `xd(${connection.id}) ${text}\n`
301+
this.sendEvent(new vscode.OutputEvent(log), true)
302+
}
303+
})
298304
await connection.waitForInitPacket()
299305

300306
// support for breakpoints

0 commit comments

Comments
 (0)