fixed logging and remove
This commit is contained in:
@@ -506,20 +506,37 @@ var REPLYTIMEOUT = 60 // seconds before replies are ignored
|
||||
// --- Logging system (bootstrap phase) ---
|
||||
// Early log: prints to console before toml/time/json are loaded.
|
||||
// Upgraded to full sink-based system after config loads (see load_log_config below).
|
||||
// The bootstrap log forwards to _log_full once the full system is ready, so that
|
||||
// modules loaded early (like shop.cm) get full logging even though they captured
|
||||
// the bootstrap function reference.
|
||||
|
||||
var log_config = null
|
||||
var channel_sinks = {}
|
||||
var wildcard_sinks = []
|
||||
var warned_channels = {}
|
||||
var stack_channels = {}
|
||||
var _log_full = null
|
||||
|
||||
var log_quiet_channels = { shop: true }
|
||||
|
||||
function log(name, args) {
|
||||
if (_log_full) return _log_full(name, args)
|
||||
if (log_quiet_channels[name]) return
|
||||
var msg = args[0]
|
||||
var stk = null
|
||||
var i = 0
|
||||
var fr = null
|
||||
if (msg == null) msg = ""
|
||||
os.print(`[${text(_cell.id, 0, 5)}] [${name}]: ${msg}\n`)
|
||||
if (name == "error") {
|
||||
stk = os.stack(2)
|
||||
if (stk && length(stk) > 0) {
|
||||
for (i = 0; i < length(stk); i = i + 1) {
|
||||
fr = stk[i]
|
||||
os.print(` at ${fr.fn} (${fr.file}:${text(fr.line)}:${text(fr.col)})\n`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function actor_die(err)
|
||||
@@ -648,6 +665,7 @@ function build_sink_routing() {
|
||||
var names = array(log_config.sink)
|
||||
arrfor(names, function(name) {
|
||||
var sink = log_config.sink[name]
|
||||
if (!sink || !is_object(sink)) return
|
||||
sink._name = name
|
||||
if (!is_array(sink.channels)) sink.channels = []
|
||||
if (is_text(sink.exclude)) sink.exclude = [sink.exclude]
|
||||
@@ -677,7 +695,7 @@ function load_log_config() {
|
||||
log_config = toml.decode(text(fd.slurp(log_path)))
|
||||
}
|
||||
}
|
||||
if (!log_config || !log_config.sink) {
|
||||
if (!log_config || !log_config.sink || length(array(log_config.sink)) == 0) {
|
||||
log_config = {
|
||||
sink: {
|
||||
terminal: {
|
||||
@@ -787,6 +805,10 @@ log = function(name, args) {
|
||||
// Wire C-level JS_Log through the ƿit log system
|
||||
actor_mod.set_log(log)
|
||||
|
||||
// Let the bootstrap log forward to the full system — modules loaded early
|
||||
// (before the full log was ready) captured the bootstrap function reference.
|
||||
_log_full = log
|
||||
|
||||
var pronto = use_core('pronto')
|
||||
var fallback = pronto.fallback
|
||||
var parallel = pronto.parallel
|
||||
|
||||
Reference in New Issue
Block a user