mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-21 11:05:08 +02:00
405423108f
Co-authored-by: rebuilt <memoryman51@hotmail.com>
29 lines
703 B
Lua
29 lines
703 B
Lua
local Log = {}
|
|
|
|
--- Creates a log handle based on Plenary.log
|
|
---@param opts these are passed verbatim to Plenary.log
|
|
---@return log handle
|
|
function Log:new(opts)
|
|
local status_ok, _ = pcall(require, "plenary.log")
|
|
if not status_ok then
|
|
return nil
|
|
end
|
|
|
|
local obj = require("plenary.log").new(opts)
|
|
local path = string.format("%s/%s.log", vim.api.nvim_call_function("stdpath", { "cache" }), opts.plugin)
|
|
|
|
obj.get_path = function()
|
|
return path
|
|
end
|
|
|
|
return obj
|
|
end
|
|
|
|
--- Creates or retrieves a log handle for the default logfile
|
|
--- based on Plenary.log
|
|
---@return log handle
|
|
function Log:get_default()
|
|
return Log:new { plugin = "lunarvim", level = lvim.log.level }
|
|
end
|
|
|
|
return Log
|