change _debug to _syslog
This commit is contained in:
@@ -120,10 +120,10 @@ table.sort(context.tasks, function(a, b)
|
||||
return a.priority < b.priority
|
||||
end)
|
||||
|
||||
_G._debug('Tasks\n-----')
|
||||
_G._syslog('Tasks\n-----')
|
||||
for _, task in ipairs(context.tasks) do
|
||||
task.execTime = 0
|
||||
_G._debug('%d: %s', task.priority, task.name)
|
||||
_G._syslog('%d: %s', task.priority, task.name)
|
||||
end
|
||||
|
||||
Milo:clearGrid()
|
||||
@@ -139,8 +139,8 @@ Event.on({ 'milo_cycle', 'milo_queue' }, function(e)
|
||||
for _, entry in pairs(queue) do
|
||||
local s, m = pcall(entry.callback, entry.request)
|
||||
if not s and m then
|
||||
_G._debug('callback crashed')
|
||||
_G._debug(m)
|
||||
_G._syslog('callback crashed')
|
||||
_G._syslog(m)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -154,8 +154,8 @@ Event.on({ 'milo_cycle', 'milo_queue' }, function(e)
|
||||
local timer = Util.timer()
|
||||
local s, m = pcall(function() task:cycle(context) end)
|
||||
if not s and m then
|
||||
_G._debug(task.name .. ' crashed')
|
||||
_G._debug(m)
|
||||
_G._syslog(task.name .. ' crashed')
|
||||
_G._syslog(m)
|
||||
end
|
||||
task.execTime = task.execTime + timer()
|
||||
end
|
||||
@@ -182,7 +182,7 @@ cycleHandle = Event.onInterval(5, function()
|
||||
Event.trigger('milo_cycle')
|
||||
if context.taskCounter > 0 then
|
||||
--local average = context.taskTimer / context.taskCounter
|
||||
--_debug('Interval: ' .. math.max(5, 2 + average * 3))
|
||||
--_syslog('Interval: ' .. math.max(5, 2 + average * 3))
|
||||
--cycleHandle.updateInterval(math.max(5, 2 + average * 3))
|
||||
end
|
||||
end)
|
||||
@@ -208,8 +208,8 @@ os.queueEvent(
|
||||
context.storage:isOnline() and 'storage_online' or 'storage_offline',
|
||||
context.storage:isOnline())
|
||||
|
||||
local oldDebug = _G._debug
|
||||
_G._debug = function(...)
|
||||
local oldDebug = _G._syslog
|
||||
_G._syslog = function(...)
|
||||
for _,v in pairs(context.loggers) do
|
||||
v(...)
|
||||
end
|
||||
@@ -220,5 +220,5 @@ local s, m = pcall(function()
|
||||
UI:pullEvents()
|
||||
end)
|
||||
|
||||
_G._debug = oldDebug
|
||||
_G._syslog = oldDebug
|
||||
if not s then error(m) end
|
||||
|
||||
@@ -148,7 +148,7 @@ local function turtleCraft(recipe, storage, request, count)
|
||||
request.status = 'rescan needed ?'
|
||||
request.statusCode = Craft.STATUS_ERROR
|
||||
failed = true
|
||||
_debug('failed to export: ' .. item.name)
|
||||
_G._syslog('failed to export: ' .. item.name)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@@ -165,8 +165,8 @@ local function turtleCraft(recipe, storage, request, count)
|
||||
local l = storage.turtleInventory.adapter.list()
|
||||
local crafted = l[1]
|
||||
if recipe.result ~= itemDB:makeKey(crafted) then
|
||||
_debug('expected: ' .. recipe.result)
|
||||
_debug('got: ' .. itemDB:makeKey(crafted))
|
||||
_G._syslog('expected: ' .. recipe.result)
|
||||
_G._syslog('got: ' .. itemDB:makeKey(crafted))
|
||||
request.aborted = true
|
||||
request.status = 'Failed to craft: ' .. recipe.result
|
||||
request.statusCode = Craft.STATUS_ERROR
|
||||
@@ -176,7 +176,7 @@ local function turtleCraft(recipe, storage, request, count)
|
||||
request.statusCode = Craft.STATUS_SUCCESS
|
||||
end
|
||||
else
|
||||
_debug('just failed')
|
||||
_G._syslog('just failed')
|
||||
request.status = 'Failed to craft'
|
||||
request.statusCode = Craft.STATUS_ERROR
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ function Adapter:init(args)
|
||||
end
|
||||
|
||||
function self.pullItems(target, key, amount, slot)
|
||||
_G._debug({target, key, amount, slot })
|
||||
_G._syslog({target, key, amount, slot })
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ function Storage:init()
|
||||
end
|
||||
|
||||
Event.on({ 'device_attach', 'device_detach' }, function(e, dev)
|
||||
_G._debug('%s: %s', e, tostring(dev))
|
||||
_G._syslog('%s: %s', e, tostring(dev))
|
||||
self:initStorage()
|
||||
end)
|
||||
Event.onInterval(60, function()
|
||||
@@ -87,11 +87,11 @@ function Storage:showStorage()
|
||||
end
|
||||
end
|
||||
if #t > 0 then
|
||||
_G._debug('Adapter:')
|
||||
_G._syslog('Adapter:')
|
||||
for _, k in pairs(t) do
|
||||
_G._debug(' offline: ' .. k)
|
||||
_G._syslog(' offline: ' .. k)
|
||||
end
|
||||
_G._debug('')
|
||||
_G._syslog('')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -143,7 +143,7 @@ function Storage:initStorage()
|
||||
self.storageOnline = online
|
||||
-- TODO: if online, then list items
|
||||
os.queueEvent(self.storageOnline and 'storage_online' or 'storage_offline', online)
|
||||
_G._debug('Storage: %s', self.storageOnline and 'online' or 'offline')
|
||||
_G._syslog('Storage: %s', self.storageOnline and 'online' or 'offline')
|
||||
end
|
||||
|
||||
self:listItems()
|
||||
@@ -229,7 +229,7 @@ end
|
||||
|
||||
function Storage:refresh(throttle)
|
||||
self.dirty = true
|
||||
_G._debug('STORAGE: Forcing full refresh')
|
||||
_G._syslog('STORAGE: Forcing full refresh')
|
||||
for _, adapter in self:onlineAdapters() do
|
||||
adapter.dirty = true
|
||||
end
|
||||
@@ -280,7 +280,7 @@ function Storage:listItems(throttle)
|
||||
end
|
||||
end
|
||||
itemDB:flush()
|
||||
_G._debug('STORAGE: refresh ' .. #t .. ' inventories in ' .. Util.round(timer(), 2))
|
||||
_G._syslog('STORAGE: refresh ' .. #t .. ' inventories in ' .. Util.round(timer(), 2))
|
||||
|
||||
self.dirty = false
|
||||
self.cache = cache
|
||||
@@ -300,7 +300,7 @@ function Storage:updateCache(adapter, item, count)
|
||||
|
||||
if not entry then
|
||||
if count < 0 then
|
||||
_G._debug('STORAGE: update cache - count < 0', 4)
|
||||
_G._syslog('STORAGE: update cache - count < 0', 4)
|
||||
else
|
||||
entry = Util.shallowCopy(item)
|
||||
entry.count = count
|
||||
@@ -315,7 +315,7 @@ function Storage:updateCache(adapter, item, count)
|
||||
end
|
||||
|
||||
if not entry then
|
||||
_G._debug('STORAGE: item missing details')
|
||||
_G._syslog('STORAGE: item missing details')
|
||||
adapter.dirty = true
|
||||
self.dirty = true
|
||||
else
|
||||
@@ -401,7 +401,7 @@ local function rawExport(source, target, item, qty, slot)
|
||||
end)
|
||||
|
||||
if not s and m then
|
||||
_G._debug(m)
|
||||
_G._syslog(m)
|
||||
end
|
||||
|
||||
return total, m
|
||||
@@ -424,7 +424,7 @@ function Storage:export(target, slot, count, item)
|
||||
end
|
||||
|
||||
if amount > 0 then
|
||||
_G._debug('EXT: %s(%d): %s -> %s%s in %s',
|
||||
_G._syslog('EXT: %s(%d): %s -> %s%s in %s',
|
||||
item.displayName or item.name, amount, self:_sn(adapter.name), self:_sn(target.name),
|
||||
slot and string.format('[%d]', slot) or '[*]', Util.round(timer(), 2))
|
||||
end
|
||||
@@ -443,7 +443,7 @@ function Storage:export(target, slot, count, item)
|
||||
end
|
||||
end
|
||||
|
||||
_G._debug('STORAGE warning: %s(%d): %s%s %s failed to export',
|
||||
_G._syslog('STORAGE warning: %s(%d): %s%s %s failed to export',
|
||||
item.displayName or item.name, count, self:_sn(target.name),
|
||||
slot and string.format('[%d]', slot) or '[*]', key)
|
||||
|
||||
@@ -460,15 +460,15 @@ local function rawInsert(source, target, slot, qty)
|
||||
|
||||
local s, m = pcall(function()
|
||||
if isValidTransfer(source, target.name) then
|
||||
--_debug('pull %s %s %d %d', source.name, target.name, slot, qty)
|
||||
--_syslog('pull %s %s %d %d', source.name, target.name, slot, qty)
|
||||
count = source.pullItems(target.name, slot, qty)
|
||||
else
|
||||
--_debug('push %s %s', target.name, source.name)
|
||||
--_syslog('push %s %s', target.name, source.name)
|
||||
count = target.pushItems(source.name, slot, qty)
|
||||
end
|
||||
end)
|
||||
if not s and m then
|
||||
_G._debug(m)
|
||||
_G._syslog(m)
|
||||
end
|
||||
|
||||
if count > 0 then
|
||||
@@ -510,7 +510,7 @@ function Storage:import(source, slot, count, item)
|
||||
if amount > 0 then
|
||||
self:updateCache(adapter, item, amount)
|
||||
|
||||
_G._debug('INS: %s(%d): %s[%d] -> %s in %s',
|
||||
_G._syslog('INS: %s(%d): %s[%d] -> %s in %s',
|
||||
item.displayName or item.name, amount,
|
||||
self:_sn(source.name), slot, self:_sn(adapter.name), Util.round(timer(), 2))
|
||||
|
||||
@@ -557,7 +557,7 @@ function Storage:import(source, slot, count, item)
|
||||
end
|
||||
|
||||
if count ~= 0 then
|
||||
_G._debug('STORAGE warning: %s(%d): %s -> INSERT failed',
|
||||
_G._syslog('STORAGE warning: %s(%d): %s -> INSERT failed',
|
||||
item.displayName or item.name, count,
|
||||
self:_sn(source.name))
|
||||
end
|
||||
@@ -579,17 +579,17 @@ function Storage:trash(source, slot, count, item)
|
||||
amount = target.adapter.pullItems(source.name, slot, count)
|
||||
end
|
||||
|
||||
_G._debug('TRA: %s(%d): %s%s -> %s in %s',
|
||||
_G._syslog('TRA: %s(%d): %s%s -> %s in %s',
|
||||
item.displayName or item.name, amount, self:_sn(source.name),
|
||||
slot and string.format('[%d]', slot) or '[*]', self:_sn(target.name), Util.round(timer(), 2))
|
||||
end)
|
||||
if not s and m then
|
||||
_G._debug(m)
|
||||
_G._syslog(m)
|
||||
end
|
||||
end
|
||||
|
||||
if amount ~= count then
|
||||
_G._debug('STORAGE warning: %s(%d): %s -> TRASH failed',
|
||||
_G._syslog('STORAGE warning: %s(%d): %s -> TRASH failed',
|
||||
item.displayName or item.name, count - amount,
|
||||
self:_sn(source.name))
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ function TaskRunner:run()
|
||||
end
|
||||
|
||||
function TaskRunner:onError(msg)
|
||||
_G._debug(msg.errorMsg .. msg)
|
||||
_G._syslog(msg.errorMsg .. msg)
|
||||
end
|
||||
|
||||
return TaskRunner
|
||||
|
||||
@@ -82,7 +82,7 @@ local function backupNode(node)
|
||||
}
|
||||
local s, m = pcall(function()
|
||||
if not node.adapter.isDiskPresent() then
|
||||
_G._debug('BACKUP error: No media present')
|
||||
_G._syslog('BACKUP error: No media present')
|
||||
else
|
||||
local dir = node.adapter.getMountPath()
|
||||
for _, v in pairs(files) do
|
||||
@@ -91,7 +91,7 @@ local function backupNode(node)
|
||||
end
|
||||
end)
|
||||
if not s and m then
|
||||
_G._debug('BACKUP error:' .. m)
|
||||
_G._syslog('BACKUP error:' .. m)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,7 +105,7 @@ function BackupTask:cycle()
|
||||
for node in context.storage:filterActive('backup') do
|
||||
if not drives[node.name] then
|
||||
drives[node.name] = Event.onInterval(DAY, function()
|
||||
_G._debug('BACKUP: started')
|
||||
_G._syslog('BACKUP: started')
|
||||
if node.adapter and node.adapter.online then
|
||||
backupNode(node)
|
||||
end
|
||||
|
||||
@@ -75,7 +75,7 @@ function ImportTask:cycle(context)
|
||||
end
|
||||
|
||||
function tasks:onError(msg)
|
||||
_G._debug('IMPORT error: ' .. msg)
|
||||
_G._syslog('IMPORT error: ' .. msg)
|
||||
end
|
||||
tasks:run()
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ function RefreshTask:cycle(context)
|
||||
for node, adapter in context.storage:onlineAdapters() do
|
||||
if node.refreshInterval then
|
||||
if not adapter.lastRefresh or adapter.lastRefresh + node.refreshInterval < now then
|
||||
_G._debug('REFRESHER: ' .. (node.displayName or node.name))
|
||||
_G._syslog('REFRESHER: ' .. (node.displayName or node.name))
|
||||
context.storage.dirty = true
|
||||
adapter.dirty = true
|
||||
adapter.lastRefresh = now
|
||||
|
||||
@@ -13,7 +13,7 @@ local function getNameSafe(v)
|
||||
name = v.getName()
|
||||
end)
|
||||
if not s then
|
||||
_G._debug(m)
|
||||
_G._syslog(m)
|
||||
end
|
||||
return name
|
||||
end
|
||||
@@ -35,7 +35,7 @@ local function compactList(list)
|
||||
end
|
||||
|
||||
local function client(socket)
|
||||
_G._debug('REMOTE: connection from ' .. socket.dhost)
|
||||
_G._syslog('REMOTE: connection from ' .. socket.dhost)
|
||||
|
||||
local user = socket:read(2)
|
||||
if not user then
|
||||
@@ -44,7 +44,7 @@ local function client(socket)
|
||||
|
||||
local manipulator = getManipulatorForUser(user)
|
||||
if not manipulator then
|
||||
_G._debug('REMOTE: Manipulator with introspection module bound with user not found. Closing connection.')
|
||||
_G._syslog('REMOTE: Manipulator with introspection module bound with user not found. Closing connection.')
|
||||
socket:write({
|
||||
msg = 'Manipulator not found'
|
||||
})
|
||||
@@ -52,7 +52,7 @@ local function client(socket)
|
||||
return
|
||||
end
|
||||
|
||||
_G._debug('REMOTE: all good')
|
||||
_G._syslog('REMOTE: all good')
|
||||
socket:write({
|
||||
data = 'ok',
|
||||
})
|
||||
@@ -166,7 +166,7 @@ local function client(socket)
|
||||
end
|
||||
until not socket.connected
|
||||
|
||||
_G._debug('REMOTE: disconnected from ' .. socket.dhost)
|
||||
_G._syslog('REMOTE: disconnected from ' .. socket.dhost)
|
||||
end
|
||||
|
||||
local handler
|
||||
@@ -174,7 +174,7 @@ local handler
|
||||
local function listen()
|
||||
if device.wireless_modem then
|
||||
handler = Event.addRoutine(function()
|
||||
_G._debug('REMOTE: listening on port 4242')
|
||||
_G._syslog('REMOTE: listening on port 4242')
|
||||
while true do
|
||||
local socket = Socket.server(4242)
|
||||
Event.addRoutine(function()
|
||||
@@ -191,7 +191,7 @@ Event.on({ 'device_attach', 'device_detach' }, function(_, name)
|
||||
if handler then
|
||||
handler:terminate()
|
||||
handler = nil
|
||||
_G._debug('REMOTE: wireless modem disconnected')
|
||||
_G._syslog('REMOTE: wireless modem disconnected')
|
||||
else
|
||||
listen()
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ Event.addRoutine(function()
|
||||
end
|
||||
end)
|
||||
if not s and m then
|
||||
_G._debug(m)
|
||||
_G._syslog(m)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -92,7 +92,7 @@ Event.onInterval(5, function()
|
||||
end
|
||||
end)
|
||||
if not s and m then
|
||||
_G._debug(m)
|
||||
_G._syslog(m)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user