From ebd0896ee9a2de57cb33a201c2ac28512e1a13d9 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sat, 16 Mar 2019 21:02:49 -0400 Subject: [PATCH] milo logging --- milo/apis/storage.lua | 15 +++++++++------ milo/plugins/exportTask.lua | 7 ++++++- milo/plugins/importTask.lua | 5 ++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/milo/apis/storage.lua b/milo/apis/storage.lua index 7aea941..14341b5 100644 --- a/milo/apis/storage.lua +++ b/milo/apis/storage.lua @@ -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 diff --git a/milo/plugins/exportTask.lua b/milo/plugins/exportTask.lua index 5114f30..561c55d 100644 --- a/milo/plugins/exportTask.lua +++ b/milo/plugins/exportTask.lua @@ -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 diff --git a/milo/plugins/importTask.lua b/milo/plugins/importTask.lua index f27a830..29050af 100644 --- a/milo/plugins/importTask.lua +++ b/milo/plugins/importTask.lua @@ -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