committed by
GitHub
parent
2457e141ae
commit
a65078e3ae
@@ -191,6 +191,7 @@ require'nvim-tree'.setup {
|
|||||||
},
|
},
|
||||||
log = {
|
log = {
|
||||||
enable = false,
|
enable = false,
|
||||||
|
truncate = false,
|
||||||
types = {
|
types = {
|
||||||
all = false,
|
all = false,
|
||||||
config = false,
|
config = false,
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ function.
|
|||||||
},
|
},
|
||||||
log = {
|
log = {
|
||||||
enable = false,
|
enable = false,
|
||||||
|
truncate = false,
|
||||||
types = {
|
types = {
|
||||||
all = false,
|
all = false,
|
||||||
config = false,
|
config = false,
|
||||||
@@ -476,6 +477,10 @@ Here is a list of the options available in the setup call:
|
|||||||
type: `boolean`
|
type: `boolean`
|
||||||
default: `false`
|
default: `false`
|
||||||
|
|
||||||
|
- |log.truncate|: remove existing log file at startup
|
||||||
|
type: `boolean`
|
||||||
|
default: `false`
|
||||||
|
|
||||||
- |log.types|: specify which information to log
|
- |log.types|: specify which information to log
|
||||||
|
|
||||||
- |log.types.all|: everything
|
- |log.types.all|: everything
|
||||||
|
|||||||
@@ -395,6 +395,7 @@ local DEFAULT_OPTS = {
|
|||||||
},
|
},
|
||||||
log = {
|
log = {
|
||||||
enable = false,
|
enable = false,
|
||||||
|
truncate = false,
|
||||||
types = {
|
types = {
|
||||||
all = false,
|
all = false,
|
||||||
config = false,
|
config = false,
|
||||||
|
|||||||
@@ -19,20 +19,23 @@ function M.raw(typ, fmt, ...)
|
|||||||
io.close(file)
|
io.close(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Write to log file
|
-- Write to log file via M.raw
|
||||||
-- time and typ are prefixed and a trailing newline is added
|
-- time and typ are prefixed and a trailing newline is added
|
||||||
function M.line(typ, fmt, ...)
|
function M.line(typ, fmt, ...)
|
||||||
if not M.path or not M.config.types[typ] and not M.config.types.all then
|
if not M.path or not M.config.types[typ] and not M.config.types.all then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
M.raw(typ, string.format("[%s] [%s] %s\n", os.date "%H:%M:%S", typ, fmt), ...)
|
M.raw(typ, string.format("[%s] [%s] %s\n", os.date "%Y:%m:%d %H:%M:%S", typ, fmt), ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
M.config = opts.log
|
M.config = opts.log
|
||||||
if M.config and M.config.enable and M.config.types then
|
if M.config and M.config.enable and M.config.types then
|
||||||
M.path = string.format("%s/nvim-tree-%s-%s.log", vim.fn.stdpath "cache", os.date "%H:%M:%S", vim.env.USER)
|
M.path = string.format("%s/nvim-tree.log", vim.fn.stdpath "cache", os.date "%H:%M:%S", vim.env.USER)
|
||||||
|
if M.config.truncate then
|
||||||
|
os.remove(M.path)
|
||||||
|
end
|
||||||
print("nvim-tree.lua logging to " .. M.path)
|
print("nvim-tree.lua logging to " .. M.path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user