milo logging

This commit is contained in:
kepler155c@gmail.com
2019-03-16 21:02:49 -04:00
parent ed0dfcd473
commit ebd0896ee9
3 changed files with 19 additions and 8 deletions

View File

@@ -415,8 +415,8 @@ function Storage:export(target, slot, count, item)
self:updateCache(adapter, item, -amount)
_G._debug('EXT: %s(%d): %s -> %s%s',
item.displayName or item.name, amount, self:_sn(adapter.name), self:_sn(target.name),
slot and string.format('[%d]', slot) or '[*]')
item.displayName or item.name, amount, self:_sn(adapter.name), self:_sn(target.name),
slot and string.format('[%d]', slot) or '[*]')
end
count = count - amount
total = total + amount
@@ -514,7 +514,7 @@ function Storage:import(source, slot, count, item)
if node.lock and node.lock[key] then
insert(node.adapter, item)
if count > 0 and node.void then
total = total + self:trash(source, slot, count)
total = total + self:trash(source, slot, count, item)
return total
end
end
@@ -549,13 +549,16 @@ function Storage:import(source, slot, count, item)
end
-- When importing items into a locked chest, trash any remaining items if full
function Storage:trash(source, slot, count)
function Storage:trash(source, slot, count, item)
local target = Util.find(self.nodes, 'mtype', 'trashcan')
local amount = 0
if target and target.adapter and target.adapter.online then
local s, m = pcall(function()
_G._debug('TRA: %s[%d] (%d)', self:_sn(source.name), slot, count or 64)
--return trashcan.adapter.pullItems(source.name, slot, count)
_G._debug('TRA: %s(%d): %s%s -> %s',
item.displayName or item.name, count, self:_sn(source.name),
slot and string.format('[%d]', slot) or '[*]', self:_sn(target.name))
--_G._debug('TRA: %s[%d] (%d)', self:_sn(source.name), slot, count or 64)
if isValidTransfer(source.adapter, target.name) then
amount = source.adapter.pushItems(target.name, slot, count)
else

View File

@@ -54,7 +54,10 @@ function ExportTask:cycle(context)
local _, item = next(items)
if item then
local count = math.min(item.count, itemDB:getMaxCount(item))
context.storage:export(node, entry.slot, count, item)
if context.storage:export(node, entry.slot, count, item) ~= count then
_G._debug('EXPORTER warning: Failed to export %s(%d) %s[%d]',
node.displayName or node.name, entry.slot, item.name, count)
end
break
end
end
@@ -67,6 +70,8 @@ function ExportTask:cycle(context)
if context.storage:export(node, nil, item.count, item) == 0 then
-- TODO: really shouldn't break here as there may be room in other slots
-- leaving for now for performance reasons
_G._debug('EXPORTER warning: Failed to export %s %s[%d]',
node.displayName or node.name, item.name, item.count)
break
end
end

View File

@@ -55,7 +55,10 @@ function ImportTask:cycle(context)
return node.adapter.getItemMeta(slotNo)
end)
if item and matchesFilter(item) then
context.storage:import(node, slotNo, item.count, item)
if context.storage:import(node, slotNo, item.count, item) ~= item.count then
_G._debug('IMPORTER warning: Failed to import %s(%d) %s[%d]',
node.displayName or node.name, slotNo, item.name, item.count)
end
end
end