diff options
author | kylo252 <[email protected]> | 2021-10-10 21:07:41 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2021-10-10 21:07:41 +0200 |
commit | 52b74557415eb757ad4b7481b0aec8a3f98dd58d (patch) | |
tree | 9a05ec71a46c99fbdf8df0043be652b528c7c04e /lua/core/log.lua | |
parent | e2c85df440564a62fd804555747b1652a6844a5e (diff) |
feat: add an independent lvim namespace (#1699)
Diffstat (limited to 'lua/core/log.lua')
-rw-r--r-- | lua/core/log.lua | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/lua/core/log.lua b/lua/core/log.lua deleted file mode 100644 index fca1fcb4..00000000 --- a/lua/core/log.lua +++ /dev/null @@ -1,60 +0,0 @@ -local Log = {} - ---- Adds a log entry using Plenary.log ----@param msg any ----@param level string [same as vim.log.log_levels] -function Log:add_entry(msg, level) - assert(type(level) == "string") - if self.__handle then - -- plenary uses lower-case log levels - self.__handle[level:lower()](msg) - return - end - local status_ok, plenary = pcall(require, "plenary") - if status_ok then - local default_opts = { plugin = "lunarvim", level = lvim.log.level } - local handle = plenary.log.new(default_opts) - handle[level:lower()](msg) - self.__handle = handle - end - -- don't do anything if plenary is not available -end - ----Retrieves the path of the logfile ----@return string path of the logfile -function Log:get_path() - return string.format("%s/%s.log", vim.fn.stdpath "cache", "lunarvim") -end - ----Add a log entry at TRACE level ----@param msg any -function Log:trace(msg) - self:add_entry(msg, "TRACE") -end - ----Add a log entry at DEBUG level ----@param msg any -function Log:debug(msg) - self:add_entry(msg, "DEBUG") -end - ----Add a log entry at INFO level ----@param msg any -function Log:info(msg) - self:add_entry(msg, "INFO") -end - ----Add a log entry at WARN level ----@param msg any -function Log:warn(msg) - self:add_entry(msg, "WARN") -end - ----Add a log entry at ERROR level ----@param msg any -function Log:error(msg) - self:add_entry(msg, "ERROR") -end - -setmetatable({}, Log) -return Log |