log is a proxy now
This commit is contained in:
@@ -122,26 +122,28 @@ function console_rec(line, file, msg) {
|
||||
// time: [${time.text("mb d yyyy h:nn:ss")}]
|
||||
}
|
||||
|
||||
globalThis.log = {}
|
||||
log.console = function(msg)
|
||||
{
|
||||
var caller = caller_data(1)
|
||||
globalThis.log = function(name, args) {
|
||||
var caller = caller_data(2)
|
||||
var msg = args[0]
|
||||
|
||||
switch(name) {
|
||||
case 'console':
|
||||
os.print(console_rec(caller.line, caller.file, msg))
|
||||
}
|
||||
|
||||
log.error = function(msg = new Error())
|
||||
{
|
||||
var caller = caller_data(1)
|
||||
|
||||
break
|
||||
case 'error':
|
||||
msg = msg ?? new Error()
|
||||
if (is_proto(msg, Error))
|
||||
msg = msg.name + ": " + msg.message + "\n" + msg.stack
|
||||
|
||||
os.print(console_rec(caller.line, caller.file, msg))
|
||||
}
|
||||
|
||||
log.system = function(msg) {
|
||||
break
|
||||
case 'system':
|
||||
msg = "[SYSTEM] " + msg
|
||||
log.console(msg)
|
||||
os.print(console_rec(caller.line, caller.file, msg))
|
||||
break
|
||||
default:
|
||||
log.console(`unknown log type: ${name}`)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function disrupt(err)
|
||||
|
||||
Reference in New Issue
Block a user