tsubasa:~$ highlight -S lua -O bbcode src/lua/undefined/undefined/debug.lua
local g = require 'glib'
function print ( line )
io.stderr:write ( os.date ( '[%H:%M:%S] ' ) )
io.stderr:write ( line or '' )
io.stderr:write ( '\n' )
end
local function g_log_handler ( domain, loglevel, m )
print ( ( domain or 'NULL' ) .. ': ' .. ( m or '' ) )
end
g.log.handler ( 'lua-lm', 0xFF, g_log_handler )
g.log.handler ( 'lua-glib', 0xFF, g_log_handler )
g.log.handler ( g_log_handler )
-- during log handler run can occur gc. that will eat some llm object,
-- causin' another log run, that will be considered recursive,
-- that is fatal
g.log.set_fatal ( 'lua-lm', { 'error' } )
g.log.set_fatal ( 'lua-glib', { 'error' } )
g.log.set_always_fatal ( { 'error' } )
-- dammit, all this mess, and I still unable to intercept those recursive
-- messages! but at least they are now not so deadly...
local M = {
__index =
function ( t, v )
error ( ('global variable %q accessed at %s'):format ( tostring ( v ), debug.traceback () ) )
end,
__newindex =
function ( t, v, k )
error ( ('global variable %q assigned %q at %s'):format ( tostring ( v ), tostring ( k ), debug.traceback () ) )
end,
}
setmetatable ( _G, M )
print ( 'Debug log started.' )