change _debug to _syslog

This commit is contained in:
kepler155c@gmail.com 2019-05-03 15:30:09 -04:00
parent 59552d4217
commit c44dc765da
6 changed files with 22 additions and 26 deletions

View File

@ -100,9 +100,9 @@ function Terminal.window(parent, sx, sy, w, h, isVisible)
end end
function win.setCursorPos(x, y) function win.setCursorPos(x, y)
cx, cy = x, y cx, cy = math.floor(x), math.floor(y)
if isVisible then if isVisible then
parent.setCursorPos(x + canvas.x - 1, y + canvas.y - 1) parent.setCursorPos(cx + canvas.x - 1, cy + canvas.y - 1)
end end
end end

View File

@ -85,7 +85,7 @@ return function (fn, ...)
end end
for _, line in pairs(trace) do for _, line in pairs(trace) do
_G._debug(line) _G._syslog(line)
end end
-- If this traceback is more than 15 elements long, keep the first 9, last 5 -- If this traceback is more than 15 elements long, keep the first 9, last 5

View File

@ -199,13 +199,15 @@ function Canvas:blit(x, y, text, bg, fg)
end end
local line = self.lines[y] local line = self.lines[y]
line.dirty = true if line then
line.text = replace(line.text, x, text, width) line.dirty = true
if fg then line.text = replace(line.text, x, text, width)
line.fg = replace(line.fg, x, fg, width) if fg then
end line.fg = replace(line.fg, x, fg, width)
if bg then end
line.bg = replace(line.bg, x, bg, width) if bg then
line.bg = replace(line.bg, x, bg, width)
end
end end
end end
end end

View File

@ -33,7 +33,7 @@ function transport.read(socket)
end end
function transport.write(socket, data) function transport.write(socket, data)
--_debug('>> ' .. Util.tostring({ type = 'DATA', seq = socket.wseq })) --_syslog('>> ' .. Util.tostring({ type = 'DATA', seq = socket.wseq }))
socket.transmit(socket.dport, socket.dhost, data) socket.transmit(socket.dport, socket.dhost, data)
--local timerId = os.startTimer(3) --local timerId = os.startTimer(3)
@ -45,7 +45,7 @@ function transport.write(socket, data)
end end
function transport.ping(socket) function transport.ping(socket)
--_debug('>> ' .. Util.tostring({ type = 'DATA', seq = socket.wseq })) --_syslog('>> ' .. Util.tostring({ type = 'DATA', seq = socket.wseq }))
if os.clock() - socket.activityTimer > 10 then if os.clock() - socket.activityTimer > 10 then
socket.activityTimer = os.clock() socket.activityTimer = os.clock()
socket.transmit(socket.dport, socket.dhost, { socket.transmit(socket.dport, socket.dhost, {
@ -78,9 +78,9 @@ Event.on('modem_message', function(_, _, dport, dhost, msg, distance)
local socket = transport.sockets[dport] local socket = transport.sockets[dport]
if socket and socket.connected then if socket and socket.connected then
--if msg.type then _debug('<< ' .. Util.tostring(msg)) end --if msg.type then _syslog('<< ' .. Util.tostring(msg)) end
if socket.co and coroutine.status(socket.co) == 'dead' then if socket.co and coroutine.status(socket.co) == 'dead' then
_G._debug('socket coroutine dead') _G._syslog('socket coroutine dead')
socket:close() socket:close()
elseif msg.type == 'DISC' then elseif msg.type == 'DISC' then
@ -111,9 +111,9 @@ Event.on('modem_message', function(_, _, dport, dhost, msg, distance)
socket.activityTimer = os.clock() socket.activityTimer = os.clock()
if msg.seq ~= socket.rseq then if msg.seq ~= socket.rseq then
print('transport seq error - closing socket ' .. socket.sport) print('transport seq error - closing socket ' .. socket.sport)
_debug(msg.data) _syslog(msg.data)
_debug('current ' .. socket.rseq) _syslog('current ' .. socket.rseq)
_debug('expected ' .. msg.seq) _syslog('expected ' .. msg.seq)
-- socket:close() -- socket:close()
-- os.queueEvent('transport_' .. socket.uid) -- os.queueEvent('transport_' .. socket.uid)
else else
@ -125,7 +125,7 @@ Event.on('modem_message', function(_, _, dport, dhost, msg, distance)
os.queueEvent('transport_' .. socket.uid) os.queueEvent('transport_' .. socket.uid)
end end
--_debug('>> ' .. Util.tostring({ type = 'ACK', seq = msg.seq })) --_syslog('>> ' .. Util.tostring({ type = 'ACK', seq = msg.seq }))
--socket.transmit(socket.dport, socket.dhost, { --socket.transmit(socket.dport, socket.dhost, {
-- type = 'ACK', -- type = 'ACK',
-- seq = msg.seq, -- seq = msg.seq,

View File

@ -11,7 +11,7 @@ for k,v in pairs(_ENV) do
sandboxEnv[k] = v sandboxEnv[k] = v
end end
_G._debug = function() end _G._syslog = function() end
local function makeEnv() local function makeEnv()
local env = setmetatable({ }, { __index = _G }) local env = setmetatable({ }, { __index = _G })

View File

@ -28,19 +28,13 @@ local focusedRoutineEvents = Util.transpose {
'paste', 'terminate', 'paste', 'terminate',
} }
_G._debug = function(pattern, ...) _G._syslog = function(pattern, ...)
local oldTerm = term.redirect(kernel.window) local oldTerm = term.redirect(kernel.window)
kernel.window.scrollBottom() kernel.window.scrollBottom()
Util.print(pattern, ...) Util.print(pattern, ...)
term.redirect(oldTerm) term.redirect(oldTerm)
end end
if not _G.debug then -- don't clobber lua debugger
function _G.debug(...)
_G._debug(...)
end
end
-- any function that runs in a kernel hook does not run in -- any function that runs in a kernel hook does not run in
-- a separate coroutine or have a window. an error in a hook -- a separate coroutine or have a window. an error in a hook
-- function will crash the system. -- function will crash the system.