diff options
author | christianchiarulli <[email protected]> | 2021-08-11 16:33:41 -0400 |
---|---|---|
committer | christianchiarulli <[email protected]> | 2021-08-11 16:33:41 -0400 |
commit | 83013c0d4f1467f546c38719c61909decfcb8151 (patch) | |
tree | 143773ea73c64d953db699e6e621926e44653fc2 /lua/core/log.lua | |
parent | f6407e0bdb9c2875bc8f186929ce183af391b2a9 (diff) | |
parent | 5a7630cac761e91335d2f25cb07a81271569c791 (diff) |
Merge branch 'rolling' of github.com:ChristianChiarulli/LunarVim
Diffstat (limited to 'lua/core/log.lua')
-rw-r--r-- | lua/core/log.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lua/core/log.lua b/lua/core/log.lua new file mode 100644 index 00000000..5dd5622e --- /dev/null +++ b/lua/core/log.lua @@ -0,0 +1,29 @@ +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 |