Skip to content

Commit

Permalink
lib.ptree.inotify: turn warnings into debug messages behind flag
Browse files Browse the repository at this point in the history
These messages seem mostly useful for module-level debugging, and have
been found confusing to appear in application output by default.
  • Loading branch information
eugeneia committed Aug 11, 2022
1 parent a3a8029 commit c76a58f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib/ptree/inotify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ local function event_has_flags(event, flags)
return bit.band(event.mask, S.c.IN[flags]) ~= 0
end

local function warn(msg, ...)
io.stderr:write(string.format(msg.."\n", ...))
DEBUG = false

local function debug(msg, ...)
if DEBUG then
io.stderr:write(string.format(msg.."\n", ...))
end
end

local function open_inotify_stream(name, events)
Expand Down Expand Up @@ -201,7 +205,7 @@ function recursive_directory_inventory_events(dir, cancel_op)
cancel=cancel }
rx_op = recompute_rx_op()
else
warn('unexpected double-add for %s', name)
debug('unexpected double-add for %s', name)
end
else
occupancy = occupancy + 1
Expand Down Expand Up @@ -239,7 +243,7 @@ function recursive_directory_inventory_events(dir, cancel_op)
occupancy = occupancy - 1
tx:put(event)
else
warn('unexpected event kind on %s: %s', event.name, event.kind)
debug('unexpected event kind on %s: %s', event.name, event.kind)
end
end
tx:put({kind='rmdir', name=dir})
Expand Down

0 comments on commit c76a58f

Please sign in to comment.