Skip to content

Make sure --dap mode only outputs dap things to stdout#291

Open
matheusgomes28 wants to merge 7 commits intorokucommunity:masterfrom
matheusgomes28:remove-dap-logging-from-stdout
Open

Make sure --dap mode only outputs dap things to stdout#291
matheusgomes28 wants to merge 7 commits intorokucommunity:masterfrom
matheusgomes28:remove-dap-logging-from-stdout

Conversation

@matheusgomes28
Copy link
Copy Markdown

Redirect the logging to stderr if in --dap mode. Seems to fix running it as a nvim-dap plugin.

@TwitchBronBron TwitchBronBron enabled auto-merge (squash) March 6, 2026 20:31
Copy link
Copy Markdown
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry, didn't mean to click approve.

I haven't had time to test this locally yet, will try and take a look next week. I'm worried this will mess up all the logging in vscode.

In the mean time, can you try fixing the lint errors that showed up from the CI process?

@TwitchBronBron TwitchBronBron disabled auto-merge March 6, 2026 20:35
@matheusgomes28 matheusgomes28 force-pushed the remove-dap-logging-from-stdout branch from eb53568 to f43563f Compare March 8, 2026 11:55
@matheusgomes28
Copy link
Copy Markdown
Author

Oops, sorry, didn't mean to click approve.

I haven't had time to test this locally yet, will try and take a look next week. I'm worried this will mess up all the logging in vscode.

In the mean time, can you try fixing the lint errors that showed up from the CI process?

@TwitchBronBron That's a fair concern. I did wonder ho the vscode extension is currently working rn. My guess is that it provides a different logging environment for the extensions?

Either way, for the nvim-dap extension it seems you can't poison stdout, so maybe we could provide an extra flag you set only when running in nvim mode that would make sure to log to stderr. Let me know what you think of this.

@TwitchBronBron
Copy link
Copy Markdown
Member

Hey @matheusgomes28, could you give this PR another test locally?

Your change was completely replacing all of the logger transports. However, we leverage those for other things like file system logging, funneling the logs back to the editor via the DebugServerLogOutputEvent, etc.

So instead, I only remove the ConsoleTransport. that way our other transports remain and we don't poison stdout.

I also refactored like 10-20 additional console.* calls to use logger, so there should not be any stdout anymore from our code.

import * as yargs from 'yargs';
import { BrightScriptDebugSession } from './debugSession/BrightScriptDebugSession';
import defaultLogger from '@rokucommunity/logger';
import { logger, removeConsoleLogger } from './logging';
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger is not used here

@matheusgomes28
Copy link
Copy Markdown
Author

Hey @matheusgomes28, could you give this PR another test locally?

Your change was completely replacing all of the logger transports. However, we leverage those for other things like file system logging, funneling the logs back to the editor via the DebugServerLogOutputEvent, etc.

So instead, I only remove the ConsoleTransport. that way our other transports remain and we don't poison stdout.

I also refactored like 10-20 additional console.* calls to use logger, so there should not be any stdout anymore from our code.

@TwitchBronBron unfortunately it did not work, here's the output from nvim-dap, notice the same initializeRequest log still printed to console somehow (?):

  Error  11:00:44 msg_show.lua_error Error executing callback:
...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:97: ...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:30: Content-Length not found in headers: [11:00:44.773][LOG  ] [dap][session] initializeRequest
Content-Length: 924

stack traceback:
	[C]: in function 'parse_chunk'
	...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:97: in function <...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:85>
   Error  11:00:44 msg_show.lua_error Error executing callback:
...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:97: cannot resume dead coroutine
stack traceback:
	[C]: in function 'parse_chunk'
	...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:97: in function <...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:85>
   Error  11:00:44 msg_show.lua_error Error executing callback:
...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:97: cannot resume dead coroutine
stack traceback:
	[C]: in function 'parse_chunk'
	...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:97: in function <...iargomes/.local/share/nvim/lazy/nvim-dap/lua/dap/rpc.lua:85>
   Warn  11:00:48 notify.warn DAP Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with your adapter or `brightscript` configuration. Check the logs for errors (:help dap.set_log_level)
11:00:48 msg_showcmd :

And this is my lazyvim config (nothing special was changed):

return {
  {
    "mfussenegger/nvim-dap",
    opts = function()
      local dap = require("dap")
      -- Register BrightScript adapter (using roku-debug via wrapper that suppresses stderr)
      dap.adapters.brightscript = {
        type = "executable",
        command = "roku-debug",
        args = { "--dap" },
      }
    end,
  },
}

I've basically pulled the current state of the repo, built and installed it with npm i -g ., the version is 0.22.6-matheus because I've added the suffix to the package.json just to make sure I am using the locally built version and not a npm cached one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants