@yuneta/gobj-js 7.13.5 → 7.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -1
- package/dist/gobj-js.cjs.js +23 -9
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +711 -699
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +23 -10
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +745 -732
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +23 -9
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +711 -699
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +23 -9
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +711 -699
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -589,6 +589,10 @@ set_log_callback(fn) // fn(level, message)
|
|
|
589
589
|
|
|
590
590
|
// Gate the DIRECT browser-console writes of all the functions above
|
|
591
591
|
set_console_log_enabled(enabled) // default: true (unchanged behaviour)
|
|
592
|
+
|
|
593
|
+
// ...and a per-LINE say over them, on top of that switch (7.13.6)
|
|
594
|
+
set_console_log_filter(fn) // fn(level, msg) -> true to print
|
|
595
|
+
set_console_log_filter(null) // default: everything prints
|
|
592
596
|
```
|
|
593
597
|
|
|
594
598
|
**Three independent output paths.** `set_console_log_enabled(false)` silences
|
|
@@ -598,6 +602,15 @@ a GUI route framework output — **including the automata/FSM trace, which arriv
|
|
|
598
602
|
as `debug`** — into its own monitor window while keeping the browser console
|
|
599
603
|
clean (gobj-ui's dev-window "Output" selector does exactly this).
|
|
600
604
|
|
|
605
|
+
**Why a filter and not just the switch.** The console write happens **before**
|
|
606
|
+
the sink is called, so nothing downstream can un-print a line: a consumer that
|
|
607
|
+
wants one CLASS of lines kept off the console — the dev monitor hiding the
|
|
608
|
+
`machine` trace's timer traffic, two `EV_TIMEOUT` lines a second for ever — can
|
|
609
|
+
only say so here. The filter decides the **console alone**: the sink still
|
|
610
|
+
receives every line, so a monitor keeps a complete record and decides
|
|
611
|
+
separately what to show. The master switch still wins, and a filter that
|
|
612
|
+
**throws** is ignored — a broken one must never be able to silence the log.
|
|
613
|
+
|
|
601
614
|
### Tracing: the `machine` trace, and the levels around it
|
|
602
615
|
|
|
603
616
|
The FSM is where things happen, so the trace of the FSM **is** the execution
|
|
@@ -614,9 +627,26 @@ gobj_global_trace_level() // the mask in force
|
|
|
614
627
|
gobj_trace_level(gobj) // global | gclass | gobj, combined
|
|
615
628
|
gobj_repr_global_trace_levels() // [{name, bit, description, set}]
|
|
616
629
|
gobj_set_deep_trace(1) // everything, everywhere
|
|
617
|
-
gobj_set_trace_machine_format(1) // 1 =
|
|
630
|
+
gobj_set_trace_machine_format(1) // 1 = simpler (DEFAULT), 0 = legacy
|
|
618
631
|
```
|
|
619
632
|
|
|
633
|
+
**Two shapes for the machine trace**, the C kernel's two, and the same default
|
|
634
|
+
(`1`, since 7.13.7):
|
|
635
|
+
|
|
636
|
+
```
|
|
637
|
+
1 🔄 EV_TIMEOUT C_TIMER^t ST_IDLE from C_TIMER^t
|
|
638
|
+
0 🔄 mach(C_TIMER^t), st: ST_IDLE, ev: EV_TIMEOUT, ac: fi(), from(C_TIMER^t)
|
|
639
|
+
🔀🔀 mach(C_TIMER^t), new st(ST_IDLE), prev st(ST_IDLE)
|
|
640
|
+
<- mach(C_TIMER^t), st: ST_IDLE, ev: EV_TIMEOUT, ret: 0
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
One line per transition against three. Both name the event, so anything that
|
|
644
|
+
reads the trace back by event name works across the switch. Every line is
|
|
645
|
+
prefixed by its nesting depth (two spaces per level of `__inside__`), so an
|
|
646
|
+
event sent from inside another one's action is indented under it — **keep that
|
|
647
|
+
indentation when you render the line somewhere else**; it is the only thing
|
|
648
|
+
that says a transition happened *during* another.
|
|
649
|
+
|
|
620
650
|
Levels: `machine`, `create_delete`, `create_delete2`, `subscriptions`,
|
|
621
651
|
`start_stop`, `ev_kw`, `authzs`, `states`, `gbuffers`, `timer`, `fs`,
|
|
622
652
|
`liburing`, `timer_periodic`, `liburing_timer`, `commands`. The ones that only
|
package/dist/gobj-js.cjs.js
CHANGED
|
@@ -384,7 +384,7 @@ var Event_Type = class {
|
|
|
384
384
|
function tab() {
|
|
385
385
|
return " ".repeat(Math.max(1, __inside__ * 2));
|
|
386
386
|
}
|
|
387
|
-
var __trace_machine_format__ =
|
|
387
|
+
var __trace_machine_format__ = 1;
|
|
388
388
|
function gobj_set_trace_machine_format(format) {
|
|
389
389
|
__trace_machine_format__ = Number(format) === 1 ? 1 : 0;
|
|
390
390
|
}
|
|
@@ -3016,6 +3016,19 @@ var __console_output_enabled__ = true;
|
|
|
3016
3016
|
function set_console_log_enabled(enabled) {
|
|
3017
3017
|
__console_output_enabled__ = enabled ? true : false;
|
|
3018
3018
|
}
|
|
3019
|
+
var __console_log_filter__ = null;
|
|
3020
|
+
function set_console_log_filter(fn) {
|
|
3021
|
+
__console_log_filter__ = typeof fn === "function" ? fn : null;
|
|
3022
|
+
}
|
|
3023
|
+
function console_wants(level, msg) {
|
|
3024
|
+
if (!__console_output_enabled__) return false;
|
|
3025
|
+
if (!__console_log_filter__) return true;
|
|
3026
|
+
try {
|
|
3027
|
+
return __console_log_filter__(level, msg) ? true : false;
|
|
3028
|
+
} catch (e) {
|
|
3029
|
+
return true;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3019
3032
|
var __in_log_callback__ = false;
|
|
3020
3033
|
function emit_log_callback(level, msg, hora) {
|
|
3021
3034
|
if (__log_callback__ && !__in_log_callback__) {
|
|
@@ -3063,9 +3076,9 @@ function log_error(format) {
|
|
|
3063
3076
|
let hora = current_timestamp();
|
|
3064
3077
|
if (f_error) {
|
|
3065
3078
|
if (f_error === _console.error) {
|
|
3066
|
-
if (
|
|
3079
|
+
if (console_wants("error", msg)) f_error("%c" + hora + " ERROR: " + String(msg), "color:red");
|
|
3067
3080
|
} else {
|
|
3068
|
-
if (
|
|
3081
|
+
if (console_wants("error", msg)) _console.error("%c" + hora + " ERROR: " + String(msg), "color:red");
|
|
3069
3082
|
f_error(`${hora} ERROR: ${String(msg)}`);
|
|
3070
3083
|
}
|
|
3071
3084
|
}
|
|
@@ -3076,9 +3089,9 @@ function log_warning(format) {
|
|
|
3076
3089
|
let hora = current_timestamp();
|
|
3077
3090
|
if (f_warning) {
|
|
3078
3091
|
if (f_warning === _console.warn) {
|
|
3079
|
-
if (
|
|
3092
|
+
if (console_wants("warning", msg)) f_warning("%c" + hora + " WARNING: " + String(msg), "color:yellow");
|
|
3080
3093
|
} else {
|
|
3081
|
-
if (
|
|
3094
|
+
if (console_wants("warning", msg)) _console.warn("%c" + hora + " WARNING: " + String(msg), "color:yellow");
|
|
3082
3095
|
f_warning(`${hora} WARNING: ${String(msg)}`);
|
|
3083
3096
|
}
|
|
3084
3097
|
}
|
|
@@ -3088,7 +3101,7 @@ function log_info(format) {
|
|
|
3088
3101
|
let msg = format_log(format);
|
|
3089
3102
|
let hora = current_timestamp();
|
|
3090
3103
|
if (f_info) {
|
|
3091
|
-
if (
|
|
3104
|
+
if (console_wants("info", msg)) f_info("%c" + hora + " INFO: " + String(msg), "color:cyan");
|
|
3092
3105
|
}
|
|
3093
3106
|
emit_log_callback("info", msg, hora);
|
|
3094
3107
|
}
|
|
@@ -3096,7 +3109,7 @@ function log_debug(format) {
|
|
|
3096
3109
|
let msg = format_log(format);
|
|
3097
3110
|
let hora = current_timestamp();
|
|
3098
3111
|
if (f_debug) {
|
|
3099
|
-
if (
|
|
3112
|
+
if (console_wants("debug", msg)) f_debug("%c" + hora + " DEBUG: " + String(msg), "color:silver");
|
|
3100
3113
|
}
|
|
3101
3114
|
emit_log_callback("debug", msg, hora);
|
|
3102
3115
|
}
|
|
@@ -3104,12 +3117,12 @@ function trace_msg(format) {
|
|
|
3104
3117
|
let msg = format_log(format);
|
|
3105
3118
|
let hora = current_timestamp();
|
|
3106
3119
|
if (f_debug) {
|
|
3107
|
-
if (
|
|
3120
|
+
if (console_wants("msg", msg)) f_debug("%c" + hora + " MSG: " + String(msg), "color:cyan");
|
|
3108
3121
|
}
|
|
3109
3122
|
emit_log_callback("msg", msg, hora);
|
|
3110
3123
|
}
|
|
3111
3124
|
function trace_json(jn, msg) {
|
|
3112
|
-
if (
|
|
3125
|
+
if (console_wants("json", msg)) {
|
|
3113
3126
|
if (msg) window.console.warn("=====> " + msg);
|
|
3114
3127
|
window.console.dir(jn);
|
|
3115
3128
|
}
|
|
@@ -6861,6 +6874,7 @@ exports.safeSrc = safeSrc;
|
|
|
6861
6874
|
exports.sdata_flag_t = sdata_flag_t;
|
|
6862
6875
|
exports.send_http_json_post = send_http_json_post;
|
|
6863
6876
|
exports.set_console_log_enabled = set_console_log_enabled;
|
|
6877
|
+
exports.set_console_log_filter = set_console_log_filter;
|
|
6864
6878
|
exports.set_log_callback = set_log_callback;
|
|
6865
6879
|
exports.set_remote_log_functions = set_remote_log_functions;
|
|
6866
6880
|
exports.set_timeout = set_timeout;
|