diff --git a/README.md b/README.md index 442b2063..03b7748e 100644 --- a/README.md +++ b/README.md @@ -303,12 +303,25 @@ return { ## ⛑️ Tips & troubleshooting -### Issues with setting up the adapter +### Issues with setting up or using the adapter You can run `:checkhealth neotest-golang` to review common issues. If you need help, please open a discussion [here](https://github.com/fredrikaverpil/neotest-golang/discussions/new?category=configuration). +You can also enable logging to further inspect what's going on under the hood. +Neotest-golang piggybacks on the Neotest logger. You can enable it like so: + +```lua +require("neotest.logging"):set_level(vim.log.levels.INFO) +``` + +Lower the log level further to `DEBUG` or `TRACE` to get even more information. + +You can get ahold of the log file's path using +`require("neotest.logging"):get_filename()`, which usually points to your +`~/.local/state/nvim/neotest.log`. + ### Neotest is slowing down Neovim Neotest, out of the box with default settings, can appear very slow in large diff --git a/lua/neotest-golang/lib/cmd.lua b/lua/neotest-golang/lib/cmd.lua index 1ebc0d2e..1bcecd5c 100644 --- a/lua/neotest-golang/lib/cmd.lua +++ b/lua/neotest-golang/lib/cmd.lua @@ -2,6 +2,7 @@ local async = require("neotest.async") +local logger = require("neotest-golang.logging") local options = require("neotest-golang.options") local json = require("neotest-golang.lib.json") @@ -52,6 +53,8 @@ function M.test_command(go_test_required_args) cmd = M.gotestsum(go_test_required_args, json_filepath) end + logger.info("Test command: " .. table.concat(cmd, " ")) + return cmd, json_filepath end diff --git a/lua/neotest-golang/logging.lua b/lua/neotest-golang/logging.lua new file mode 100644 index 00000000..a1673ffe --- /dev/null +++ b/lua/neotest-golang/logging.lua @@ -0,0 +1,29 @@ +local M = {} + +---@type neotest.Logger +local logger = require("neotest.logging") + +local prefix = "[neotest-golang] " + +---@return neotest.Logger +function M.trace(msg) + return logger.trace(prefix .. msg) +end + +function M.debug(msg) + logger.debug(prefix .. msg) +end + +function M.info(msg) + logger.info(prefix .. msg) +end + +function M.warn(msg) + logger.warn(prefix .. msg) +end + +function M.error(msg) + logger.error(prefix .. msg) +end + +return M