mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
feat(logging): Enhanced the logging
Made a key appear on all the logs so its easy to read each sessions data instead of one big ass-file
This commit is contained in:
parent
c2b7ef3d37
commit
6e56ab4150
25
README.md
25
README.md
@ -161,22 +161,17 @@ require("harpoon").setup({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
-- This uses the wildcard api, you can check it out via branch wildcards
|
|
||||||
-- not quite ready yet for mainline.
|
|
||||||
-- Wildcards are to be used in conjunction with git worktrees (at least
|
|
||||||
-- that is my goal)
|
|
||||||
["/home/theprimeagen/personal/harpoon/{}"] = {
|
|
||||||
term = {
|
|
||||||
cmds = {
|
|
||||||
"echo hello {}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
Harpoon writes logs to a `harpoon.log` file that resides in Neovim's cache path. (`:echo stdpath("cache")` to find where that is for you.)
|
Harpoon writes logs to a `harpoon.log` file that resides in Neovim's cache
|
||||||
|
path. (`:echo stdpath("cache")` to find where that is for you.)
|
||||||
|
|
||||||
By default, logging is enabled for warnings and above. This can be changed by setting `vim.g.harpoon_log_level` variable to one of the following log levels: `trace`, `debug`, `info`, `warn`, `error`, or `fatal`. Note that this would have to be done **before** harpoon's `setup` call. Alternatively, it can be more convenient to launch Neovim with an environment variable, e.g. `> HARPOON_LOG=trace nvim`. In case both, `vim.g` and an environment variable are used, the log level set by the environment variable overrules. Supplying an invalid log level defaults back to warnings.
|
By default, logging is enabled for warnings and above. This can be changed by
|
||||||
|
setting `vim.g.harpoon_log_level` variable to one of the following log levels:
|
||||||
|
`trace`, `debug`, `info`, `warn`, `error`, or `fatal`. Note that this would
|
||||||
|
have to be done **before** harpoon's `setup` call. Alternatively, it can be
|
||||||
|
more convenient to launch Neovim with an environment variable, e.g. `>
|
||||||
|
HARPOON_LOG=trace nvim`. In case both, `vim.g` and an environment variable are
|
||||||
|
used, the log level set by the environment variable overrules. Supplying an
|
||||||
|
invalid log level defaults back to warnings.
|
||||||
|
@ -9,8 +9,8 @@ M.reload = function()
|
|||||||
require("plenary.reload").reload_module("harpoon")
|
require("plenary.reload").reload_module("harpoon")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local log_levels = { "trace", "debug", "info", "warn", "error", "fatal" }
|
||||||
local function set_log_level()
|
local function set_log_level()
|
||||||
local log_levels = { "trace", "debug", "info", "warn", "error", "fatal" }
|
|
||||||
local log_level = vim.env.HARPOON_LOG or vim.g.harpoon_log_level
|
local log_level = vim.env.HARPOON_LOG or vim.g.harpoon_log_level
|
||||||
|
|
||||||
for _, level in pairs(log_levels) do
|
for _, level in pairs(log_levels) do
|
||||||
@ -22,9 +22,27 @@ local function set_log_level()
|
|||||||
return "warn" -- default, if user hasn't set to one from log_levels
|
return "warn" -- default, if user hasn't set to one from log_levels
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local log_level = set_log_level()
|
||||||
M.log = require("plenary.log").new({
|
M.log = require("plenary.log").new({
|
||||||
plugin = "harpoon",
|
plugin = "harpoon",
|
||||||
level = set_log_level(),
|
level = log_level,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local log_key = os.time()
|
||||||
|
|
||||||
|
local function override(key)
|
||||||
|
local fn = M.log[key]
|
||||||
|
M.log[key] = function(...)
|
||||||
|
fn(log_key, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, v in pairs(log_levels) do
|
||||||
|
override(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.get_log_key = function()
|
||||||
|
return log_key
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
local Path = require("plenary.path")
|
local Path = require("plenary.path")
|
||||||
local utils = require("harpoon.utils")
|
local utils = require("harpoon.utils")
|
||||||
local log = require("harpoon.dev").log
|
local Dev = require("harpoon.dev")
|
||||||
|
local log = Dev.log
|
||||||
|
|
||||||
local config_path = vim.fn.stdpath("config")
|
local config_path = vim.fn.stdpath("config")
|
||||||
local data_path = vim.fn.stdpath("data")
|
local data_path = vim.fn.stdpath("data")
|
||||||
@ -158,6 +159,7 @@ M.setup = function(config)
|
|||||||
|
|
||||||
HarpoonConfig = complete_config
|
HarpoonConfig = complete_config
|
||||||
log.debug("setup(): Complete config", HarpoonConfig)
|
log.debug("setup(): Complete config", HarpoonConfig)
|
||||||
|
log.trace("setup(): log_key", Dev.get_log_key())
|
||||||
end
|
end
|
||||||
|
|
||||||
M.get_global_settings = function()
|
M.get_global_settings = function()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
augroup THE_PRIMEAGEN_HARPOON
|
augroup THE_PRIMEAGEN_HARPOON
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufLeave * :lua require('harpoon.mark').store_offset()
|
autocmd BufLeave,VimLeave * :lua require('harpoon.mark').store_offset()
|
||||||
augroup END
|
augroup END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user