feat(notify): add notify.threshold (#1693)

* feat: configurable notification level

add `notify.threshold` to setup opts

* feat: configurable notification level: add threshold example doc

* feat: configurable notification level: log always comes last

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
kylo252
2022-11-01 00:24:40 +01:00
committed by GitHub
parent ada2c6441d
commit 6ca6f99e76
19 changed files with 120 additions and 66 deletions

View File

@@ -373,6 +373,9 @@ Subsequent calls to setup will replace the previous configuration.
watcher = false, watcher = false,
}, },
}, },
notify = {
threshold = vim.log.levels.INFO,
},
} -- END_DEFAULT_OPTS } -- END_DEFAULT_OPTS
< <
@@ -992,6 +995,18 @@ The filter can be cleared with the `F` key by default.
Whether to filter folders or not. Whether to filter folders or not.
Type: `boolean`, Default: `true` Type: `boolean`, Default: `true`
*nvim-tree.notify*
Configuration for notification.
*nvim-tree.notify.threshold*
Specify minimum notification level, uses the values from |vim.log.levels|
Type: `enum`, Default: `vim.log.levels.INFO`
`ERROR`: hard errors e.g. failure to read from the file system.
`WARNING`: non-fatal errors e.g. unable to system open a file.
`INFO:` information only e.g. file copy path confirmation.
`DEBUG:` not used.
*nvim-tree.log* *nvim-tree.log*
Configuration for diagnostic logging. Configuration for diagnostic logging.

View File

@@ -640,6 +640,9 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
prefix = "[FILTER]: ", prefix = "[FILTER]: ",
always_show_folders = true, always_show_folders = true,
}, },
notify = {
threshold = vim.log.levels.INFO,
},
log = { log = {
enable = false, enable = false,
truncate = false, truncate = false,
@@ -686,10 +689,11 @@ local function validate_options(conf)
local override_typecheck = FIELD_OVERRIDE_TYPECHECK[k] or {} local override_typecheck = FIELD_OVERRIDE_TYPECHECK[k] or {}
if def[k] == nil then if def[k] == nil then
-- option does not exist -- option does not exist
invalid = string.format("unknown option: %s%s", prefix, k) invalid = string.format("[NvimTree] unknown option: %s%s", prefix, k)
elseif type(v) ~= type(def[k]) and not override_typecheck[type(v)] then elseif type(v) ~= type(def[k]) and not override_typecheck[type(v)] then
-- option is of the wrong type and is not a function -- option is of the wrong type and is not a function
invalid = string.format("invalid option: %s%s expected: %s actual: %s", prefix, k, type(def[k]), type(v)) invalid =
string.format("[NvimTree] invalid option: %s%s expected: %s actual: %s", prefix, k, type(def[k]), type(v))
end end
if invalid then if invalid then
@@ -709,13 +713,13 @@ local function validate_options(conf)
validate(conf, DEFAULT_OPTS, "") validate(conf, DEFAULT_OPTS, "")
if msg then if msg then
utils.notify.warn(msg .. " | see :help nvim-tree-setup for available configuration options") vim.notify_once(msg .. " | see :help nvim-tree-setup for available configuration options", vim.log.levels.WARN)
end end
end end
function M.setup(conf) function M.setup(conf)
if vim.fn.has "nvim-0.7" == 0 then if vim.fn.has "nvim-0.7" == 0 then
utils.notify.warn "nvim-tree.lua requires Neovim 0.7 or higher" vim.notify_once("nvim-tree.lua requires Neovim 0.7 or higher", vim.log.levels.WARN)
return return
end end
@@ -742,6 +746,7 @@ function M.setup(conf)
manage_netrw(opts.disable_netrw, opts.hijack_netrw) manage_netrw(opts.disable_netrw, opts.hijack_netrw)
M.config = opts M.config = opts
require("nvim-tree.notify").setup(opts)
require("nvim-tree.log").setup(opts) require("nvim-tree.log").setup(opts)
log.line("config", "default config + user") log.line("config", "default config + user")

View File

@@ -4,6 +4,7 @@ local lib = require "nvim-tree.lib"
local log = require "nvim-tree.log" local log = require "nvim-tree.log"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local core = require "nvim-tree.core" local core = require "nvim-tree.core"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
@@ -81,14 +82,14 @@ local function do_single_paste(source, dest, action_type, action_fn)
dest_stats, errmsg, errcode = uv.fs_stat(dest) dest_stats, errmsg, errcode = uv.fs_stat(dest)
if not dest_stats and errcode ~= "ENOENT" then if not dest_stats and errcode ~= "ENOENT" then
utils.notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???")) notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
return false, errmsg return false, errmsg
end end
local function on_process() local function on_process()
success, errmsg = action_fn(source, dest) success, errmsg = action_fn(source, dest)
if not success then if not success then
utils.notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???")) notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
return false, errmsg return false, errmsg
end end
end end
@@ -122,11 +123,11 @@ local function add_to_clipboard(node, clip)
for idx, _node in ipairs(clip) do for idx, _node in ipairs(clip) do
if _node.absolute_path == node.absolute_path then if _node.absolute_path == node.absolute_path then
table.remove(clip, idx) table.remove(clip, idx)
return utils.notify.info(node.absolute_path .. " removed to clipboard.") return notify.info(node.absolute_path .. " removed to clipboard.")
end end
end end
table.insert(clip, node) table.insert(clip, node)
utils.notify.info(node.absolute_path .. " added to clipboard.") notify.info(node.absolute_path .. " added to clipboard.")
end end
function M.clear_clipboard() function M.clear_clipboard()
@@ -157,7 +158,7 @@ local function do_paste(node, action_type, action_fn)
local stats, errmsg, errcode = uv.fs_stat(destination) local stats, errmsg, errcode = uv.fs_stat(destination)
if not stats and errcode ~= "ENOENT" then if not stats and errcode ~= "ENOENT" then
log.line("copy_paste", "do_paste fs_stat '%s' failed '%s'", destination, errmsg) log.line("copy_paste", "do_paste fs_stat '%s' failed '%s'", destination, errmsg)
utils.notify.error("Could not " .. action_type .. " " .. destination .. " - " .. (errmsg or "???")) notify.error("Could not " .. action_type .. " " .. destination .. " - " .. (errmsg or "???"))
return return
end end
local is_dir = stats and stats.type == "directory" local is_dir = stats and stats.type == "directory"
@@ -219,18 +220,18 @@ function M.print_clipboard()
end end
end end
return utils.notify.info(table.concat(content, "\n") .. "\n") return notify.info(table.concat(content, "\n") .. "\n")
end end
local function copy_to_clipboard(content) local function copy_to_clipboard(content)
if M.use_system_clipboard == true then if M.use_system_clipboard == true then
vim.fn.setreg("+", content) vim.fn.setreg("+", content)
vim.fn.setreg('"', content) vim.fn.setreg('"', content)
return utils.notify.info(string.format("Copied %s to system clipboard!", content)) return notify.info(string.format("Copied %s to system clipboard!", content))
else else
vim.fn.setreg('"', content) vim.fn.setreg('"', content)
vim.fn.setreg("1", content) vim.fn.setreg("1", content)
return utils.notify.info(string.format("Copied %s to neovim clipboard!", content)) return notify.info(string.format("Copied %s to neovim clipboard!", content))
end end
end end

View File

@@ -5,13 +5,14 @@ local events = require "nvim-tree.events"
local lib = require "nvim-tree.lib" local lib = require "nvim-tree.lib"
local core = require "nvim-tree.core" local core = require "nvim-tree.core"
local watch = require "nvim-tree.explorer.watch" local watch = require "nvim-tree.explorer.watch"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
local function create_and_notify(file) local function create_and_notify(file)
local ok, fd = pcall(uv.fs_open, file, "w", 420) local ok, fd = pcall(uv.fs_open, file, "w", 420)
if not ok then if not ok then
utils.notify.error("Couldn't create file " .. file) notify.error("Couldn't create file " .. file)
return return
end end
uv.fs_close(fd) uv.fs_close(fd)
@@ -71,7 +72,7 @@ function M.fn(node)
end end
if utils.file_exists(new_file_path) then if utils.file_exists(new_file_path) then
utils.notify.warn "Cannot create: file already exists" notify.warn "Cannot create: file already exists"
return return
end end
@@ -96,14 +97,14 @@ function M.fn(node)
elseif not utils.file_exists(path_to_create) then elseif not utils.file_exists(path_to_create) then
local success = uv.fs_mkdir(path_to_create, 493) local success = uv.fs_mkdir(path_to_create, 493)
if not success then if not success then
utils.notify.error("Could not create folder " .. path_to_create) notify.error("Could not create folder " .. path_to_create)
is_error = true is_error = true
break break
end end
end end
end end
if not is_error then if not is_error then
utils.notify.info(new_file_path .. " was properly created") notify.info(new_file_path .. " was properly created")
end end
events._dispatch_folder_created(new_file_path) events._dispatch_folder_created(new_file_path)
if M.enable_reload then if M.enable_reload then

View File

@@ -5,6 +5,7 @@ local utils = require "nvim-tree.utils"
local events = require "nvim-tree.events" local events = require "nvim-tree.events"
local view = require "nvim-tree.view" local view = require "nvim-tree.view"
local lib = require "nvim-tree.lib" local lib = require "nvim-tree.lib"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
@@ -44,7 +45,7 @@ end
local function remove_dir(cwd) local function remove_dir(cwd)
local handle = luv.fs_scandir(cwd) local handle = luv.fs_scandir(cwd)
if type(handle) == "string" then if type(handle) == "string" then
return utils.notify.error(handle) return notify.error(handle)
end end
while true do while true do
@@ -83,18 +84,18 @@ function M.fn(node)
if node.nodes ~= nil and not node.link_to then if node.nodes ~= nil and not node.link_to then
local success = remove_dir(node.absolute_path) local success = remove_dir(node.absolute_path)
if not success then if not success then
return utils.notify.error("Could not remove " .. node.name) return notify.error("Could not remove " .. node.name)
end end
events._dispatch_folder_removed(node.absolute_path) events._dispatch_folder_removed(node.absolute_path)
else else
local success = luv.fs_unlink(node.absolute_path) local success = luv.fs_unlink(node.absolute_path)
if not success then if not success then
return utils.notify.error("Could not remove " .. node.name) return notify.error("Could not remove " .. node.name)
end end
events._dispatch_file_removed(node.absolute_path) events._dispatch_file_removed(node.absolute_path)
clear_buffer(node.absolute_path) clear_buffer(node.absolute_path)
end end
utils.notify.info(node.absolute_path .. " was properly removed.") notify.info(node.absolute_path .. " was properly removed.")
if M.enable_reload then if M.enable_reload then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer() require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
end end

View File

@@ -3,6 +3,7 @@ local uv = vim.loop
local lib = require "nvim-tree.lib" local lib = require "nvim-tree.lib"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local events = require "nvim-tree.events" local events = require "nvim-tree.events"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
@@ -12,15 +13,15 @@ end
function M.rename(node, to) function M.rename(node, to)
if utils.file_exists(to) then if utils.file_exists(to) then
utils.notify.warn(err_fmt(node.absolute_path, to, "file already exists")) notify.warn(err_fmt(node.absolute_path, to, "file already exists"))
return return
end end
local success, err = uv.fs_rename(node.absolute_path, to) local success, err = uv.fs_rename(node.absolute_path, to)
if not success then if not success then
return utils.notify.warn(err_fmt(node.absolute_path, to, err)) return notify.warn(err_fmt(node.absolute_path, to, err))
end end
utils.notify.info(node.absolute_path .. "" .. to) notify.info(node.absolute_path .. "" .. to)
utils.rename_loaded_buffers(node.absolute_path, to) utils.rename_loaded_buffers(node.absolute_path, to)
events._dispatch_node_renamed(node.absolute_path, to) events._dispatch_node_renamed(node.absolute_path, to)
end end

View File

@@ -1,6 +1,7 @@
local a = vim.api local a = vim.api
local lib = require "nvim-tree.lib" local lib = require "nvim-tree.lib"
local notify = require "nvim-tree.notify"
local M = { local M = {
config = { config = {
@@ -43,13 +44,13 @@ function M.fn(node)
M.config.trash.require_confirm = true M.config.trash.require_confirm = true
end end
else else
utils.notify.warn "Trash is currently a UNIX only feature!" notify.warn "Trash is currently a UNIX only feature!"
return return
end end
local binary = M.config.trash.cmd:gsub(" .*$", "") local binary = M.config.trash.cmd:gsub(" .*$", "")
if vim.fn.executable(binary) == 0 then if vim.fn.executable(binary) == 0 then
utils.notify.warn(binary .. " is not executable.") notify.warn(binary .. " is not executable.")
return return
end end
@@ -71,7 +72,7 @@ function M.fn(node)
if node.nodes ~= nil and not node.link_to then if node.nodes ~= nil and not node.link_to then
trash_path(function(_, rc) trash_path(function(_, rc)
if rc ~= 0 then if rc ~= 0 then
utils.notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash") notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash")
return return
end end
events._dispatch_folder_removed(node.absolute_path) events._dispatch_folder_removed(node.absolute_path)
@@ -82,7 +83,7 @@ function M.fn(node)
else else
trash_path(function(_, rc) trash_path(function(_, rc)
if rc ~= 0 then if rc ~= 0 then
utils.notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash") notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash")
return return
end end
events._dispatch_file_removed(node.absolute_path) events._dispatch_file_removed(node.absolute_path)

View File

@@ -4,7 +4,7 @@ local a = vim.api
local log = require "nvim-tree.log" local log = require "nvim-tree.log"
local view = require "nvim-tree.view" local view = require "nvim-tree.view"
local util = require "nvim-tree.utils" local notify = require "nvim-tree.notify"
-- BEGIN_DEFAULT_MAPPINGS -- BEGIN_DEFAULT_MAPPINGS
local DEFAULT_MAPPINGS = { local DEFAULT_MAPPINGS = {
@@ -307,7 +307,7 @@ local function merge_mappings(user_mappings)
if not is_empty(map.action) then if not is_empty(map.action) then
M.custom_keypress_funcs[map.action] = map.action_cb M.custom_keypress_funcs[map.action] = map.action_cb
else else
util.notify.warn "action can't be empty if action_cb provided" notify.warn "action can't be empty if action_cb provided"
end end
end end
end end

View File

@@ -1,7 +1,7 @@
local core = require "nvim-tree.core" local core = require "nvim-tree.core"
local renderer = require "nvim-tree.renderer" local renderer = require "nvim-tree.renderer"
local utils = require "nvim-tree.utils"
local Iterator = require "nvim-tree.iterators.node-iterator" local Iterator = require "nvim-tree.iterators.node-iterator"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
@@ -58,7 +58,7 @@ end
function M.fn(base_node) function M.fn(base_node)
local node = base_node.nodes and base_node or core.get_explorer() local node = base_node.nodes and base_node or core.get_explorer()
if gen_iterator()(node) then if gen_iterator()(node) then
utils.notify.warn("expansion iteration was halted after " .. M.MAX_FOLDER_DISCOVERY .. " discovered folders") notify.warn("expansion iteration was halted after " .. M.MAX_FOLDER_DISCOVERY .. " discovered folders")
end end
renderer.draw() renderer.draw()
end end

View File

@@ -1,4 +1,4 @@
local utils = require "nvim-tree.utils" local notify = require "nvim-tree.notify"
local M = {} local M = {}
@@ -30,7 +30,7 @@ local function dispatch(event_name, payload)
for _, handler in pairs(get_handlers(event_name)) do for _, handler in pairs(get_handlers(event_name)) do
local success, error = pcall(handler, payload) local success, error = pcall(handler, payload)
if not success then if not success then
utils.notify.error("Handler for event " .. event_name .. " errored. " .. vim.inspect(error)) notify.error("Handler for event " .. event_name .. " errored. " .. vim.inspect(error))
end end
end end
end end

View File

@@ -6,6 +6,7 @@ local common = require "nvim-tree.explorer.common"
local sorters = require "nvim-tree.explorer.sorters" local sorters = require "nvim-tree.explorer.sorters"
local filters = require "nvim-tree.explorer.filters" local filters = require "nvim-tree.explorer.filters"
local live_filter = require "nvim-tree.live-filter" local live_filter = require "nvim-tree.live-filter"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
@@ -52,7 +53,7 @@ end
local function get_dir_handle(cwd) local function get_dir_handle(cwd)
local handle = uv.fs_scandir(cwd) local handle = uv.fs_scandir(cwd)
if type(handle) == "string" then if type(handle) == "string" then
utils.notify.error(handle) notify.error(handle)
return return
end end
return handle return handle

View File

@@ -6,6 +6,7 @@ local common = require "nvim-tree.explorer.common"
local filters = require "nvim-tree.explorer.filters" local filters = require "nvim-tree.explorer.filters"
local sorters = require "nvim-tree.explorer.sorters" local sorters = require "nvim-tree.explorer.sorters"
local live_filter = require "nvim-tree.live-filter" local live_filter = require "nvim-tree.live-filter"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
@@ -22,7 +23,7 @@ function M.reload(node, status)
local cwd = node.link_to or node.absolute_path local cwd = node.link_to or node.absolute_path
local handle = uv.fs_scandir(cwd) local handle = uv.fs_scandir(cwd)
if type(handle) == "string" then if type(handle) == "string" then
utils.notify.error(handle) notify.error(handle)
return return
end end

View File

@@ -1,4 +1,5 @@
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
@@ -292,12 +293,12 @@ end
local function removed(opts) local function removed(opts)
if opts.auto_close then if opts.auto_close then
utils.notify.warn "auto close feature has been removed, see note in the README (tips & reminder section)" notify.warn "auto close feature has been removed, see note in the README (tips & reminder section)"
opts.auto_close = nil opts.auto_close = nil
end end
if opts.focus_empty_on_setup then if opts.focus_empty_on_setup then
utils.notify.warn "focus_empty_on_setup has been removed and will be replaced by a new startup configuration. Please remove this option. See https://bit.ly/3yJch2T" notify.warn "focus_empty_on_setup has been removed and will be replaced by a new startup configuration. Please remove this option. See https://bit.ly/3yJch2T"
end end
opts.focus_empty_on_setup = nil opts.focus_empty_on_setup = nil
end end
@@ -312,7 +313,7 @@ function M.migrate_legacy_options(opts)
end end
end end
if msg then if msg then
utils.notify.warn(msg) notify.warn(msg)
end end
-- silently move -- silently move

View File

@@ -56,7 +56,7 @@ function M.setup(opts)
if M.config.truncate then if M.config.truncate then
os.remove(M.path) os.remove(M.path)
end end
require("nvim-tree.utils").notify.debug("nvim-tree.lua logging to " .. M.path) require("nvim-tree.notify").debug("nvim-tree.lua logging to " .. M.path)
end end
end end

View File

@@ -2,12 +2,13 @@ local Marks = require "nvim-tree.marks"
local Core = require "nvim-tree.core" local Core = require "nvim-tree.core"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local FsRename = require "nvim-tree.actions.fs.rename-file" local FsRename = require "nvim-tree.actions.fs.rename-file"
local notify = require "nvim-tree.notify"
local M = {} local M = {}
function M.bulk_move() function M.bulk_move()
if #Marks.get_marks() == 0 then if #Marks.get_marks() == 0 then
utils.notify.warn "no bookmark to perform bulk move on, aborting." notify.warn "no bookmark to perform bulk move on, aborting."
return return
end end
@@ -17,7 +18,7 @@ function M.bulk_move()
return return
end end
if vim.fn.filewritable(location) ~= 2 then if vim.fn.filewritable(location) ~= 2 then
utils.notify.warn(location .. " is not writable, cannot move.") notify.warn(location .. " is not writable, cannot move.")
return return
end end

44
lua/nvim-tree/notify.lua Normal file
View File

@@ -0,0 +1,44 @@
local M = {}
local config = {
threshold = vim.log.levels.INFO,
}
local modes = {
{ name = "trace", level = vim.log.levels.TRACE },
{ name = "debug", level = vim.log.levels.DEBUG },
{ name = "info", level = vim.log.levels.INFO },
{ name = "warn", level = vim.log.levels.WARN },
{ name = "error", level = vim.log.levels.ERROR },
}
do
local has_notify, notify_plugin = pcall(require, "notify")
local dispatch = function(level, msg)
if level < config.threshold then
return
end
vim.schedule(function()
if has_notify and notify_plugin then
notify_plugin(msg, level, { title = "NvimTree" })
else
vim.notify("[NvimTree] " .. msg, level)
end
end)
end
for _, x in ipairs(modes) do
M[x.name] = function(msg, ...)
return dispatch(x.level, msg, ...)
end
end
end
function M.setup(opts)
opts = opts or {}
config.threshold = opts.notify.threshold or vim.log.levels.INFO
end
return M

View File

@@ -1,4 +1,4 @@
local utils = require "nvim-tree.utils" local notify = require "nvim-tree.notify"
local M = { local M = {
SIGN_GROUP = "NvimTreeGitSigns", SIGN_GROUP = "NvimTreeGitSigns",
@@ -68,7 +68,7 @@ end
local function nil_() end local function nil_() end
local function warn_status(git_status) local function warn_status(git_status)
utils.notify.warn( notify.warn(
'Unrecognized git state "' 'Unrecognized git state "'
.. git_status .. git_status
.. '". Please open up an issue on https://github.com/nvim-tree/nvim-tree.lua/issues with this message.' .. '". Please open up an issue on https://github.com/nvim-tree/nvim-tree.lua/issues with this message.'

View File

@@ -1,5 +1,3 @@
local has_notify, notify = pcall(require, "notify")
local a = vim.api local a = vim.api
local uv = vim.loop local uv = vim.loop
@@ -16,24 +14,6 @@ function M.path_to_matching_str(path)
return path:gsub("(%-)", "(%%-)"):gsub("(%.)", "(%%.)"):gsub("(%_)", "(%%_)") return path:gsub("(%-)", "(%%-)"):gsub("(%.)", "(%%.)"):gsub("(%_)", "(%%_)")
end end
local function notify_level(level)
return function(msg)
vim.schedule(function()
if has_notify then
notify(msg, level, { title = "NvimTree" })
else
vim.notify("[NvimTree] " .. msg, level)
end
end)
end
end
M.notify = {}
M.notify.warn = notify_level(vim.log.levels.WARN)
M.notify.error = notify_level(vim.log.levels.ERROR)
M.notify.info = notify_level(vim.log.levels.INFO)
M.notify.debug = notify_level(vim.log.levels.DEBUG)
function M.str_find(haystack, needle) function M.str_find(haystack, needle)
return vim.fn.stridx(haystack, needle) ~= -1 return vim.fn.stridx(haystack, needle) ~= -1
end end

View File

@@ -1,4 +1,5 @@
local uv = vim.loop local uv = vim.loop
local notify = require "nvim-tree.notify"
local log = require "nvim-tree.log" local log = require "nvim-tree.log"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
@@ -47,7 +48,7 @@ function Event:start()
self._fs_event, _, name = uv.new_fs_event() self._fs_event, _, name = uv.new_fs_event()
if not self._fs_event then if not self._fs_event then
self._fs_event = nil self._fs_event = nil
utils.notify.warn(string.format("Could not initialize an fs_event watcher for path %s : %s", self._path, name)) notify.warn(string.format("Could not initialize an fs_event watcher for path %s : %s", self._path, name))
return false return false
end end
@@ -64,7 +65,7 @@ function Event:start()
rc, _, name = self._fs_event:start(self._path, FS_EVENT_FLAGS, event_cb) rc, _, name = self._fs_event:start(self._path, FS_EVENT_FLAGS, event_cb)
if rc ~= 0 then if rc ~= 0 then
utils.notify.warn(string.format("Could not start the fs_event watcher for path %s : %s", self._path, name)) notify.warn(string.format("Could not start the fs_event watcher for path %s : %s", self._path, name))
return false return false
end end
@@ -88,7 +89,7 @@ function Event:destroy()
if self._fs_event then if self._fs_event then
local rc, _, name = self._fs_event:stop() local rc, _, name = self._fs_event:stop()
if rc ~= 0 then if rc ~= 0 then
utils.notify.warn(string.format("Could not stop the fs_event watcher for path %s : %s", self._path, name)) notify.warn(string.format("Could not stop the fs_event watcher for path %s : %s", self._path, name))
end end
self._fs_event = nil self._fs_event = nil
end end