@yuneta/gobj-js 7.13.6 → 7.13.8

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 CHANGED
@@ -627,9 +627,26 @@ gobj_global_trace_level() // the mask in force
627
627
  gobj_trace_level(gobj) // global | gclass | gobj, combined
628
628
  gobj_repr_global_trace_levels() // [{name, bit, description, set}]
629
629
  gobj_set_deep_trace(1) // everything, everywhere
630
- gobj_set_trace_machine_format(1) // 1 = one compact line per transition
630
+ gobj_set_trace_machine_format(1) // 1 = simpler (DEFAULT), 0 = legacy
631
631
  ```
632
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
+
633
650
  Levels: `machine`, `create_delete`, `create_delete2`, `subscriptions`,
634
651
  `start_stop`, `ev_kw`, `authzs`, `states`, `gbuffers`, `timer`, `fs`,
635
652
  `liburing`, `timer_periodic`, `liburing_timer`, `commands`. The ones that only
@@ -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__ = 0;
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
  }
@@ -2297,7 +2297,9 @@ function gobj_change_state(gobj, state_name) {
2297
2297
  gobj.current_state = new_state;
2298
2298
  let tracea = is_machine_tracing(gobj, "EV_STATE_CHANGED");
2299
2299
  let tracea_states = __trace_gobj_states__(gobj) ? true : false;
2300
- if (tracea || tracea_states) trace_machine(sprintf("🔀🔀 mach(%s%s^%s), new st(%s), prev st(%s)", !gobj.running ? "!!" : "", gobj_gclass_name(gobj), gobj_name(gobj), gobj_current_state(gobj), gobj.last_state.state_name));
2300
+ if (tracea || tracea_states) {
2301
+ if (__trace_machine_format__ === 1) {} else trace_machine(sprintf("🔀🔀 mach(%s%s^%s), new st(%s), prev st(%s)", !gobj.running ? "!!" : "", gobj_gclass_name(gobj), gobj_name(gobj), gobj_current_state(gobj), gobj.last_state.state_name));
2302
+ }
2301
2303
  return true;
2302
2304
  }
2303
2305
  /***************************************************************************
@@ -2490,7 +2492,8 @@ function gobj_send_event(dst, event, kw, src) {
2490
2492
  if (dst.gclass.gmt.mt_inject_event) {
2491
2493
  __inside__--;
2492
2494
  if (tracea) {
2493
- trace_machine(sprintf("🔃 mach(%s%s), st: %s, ev: %s, from(%s%s)", !dst.running ? "!!" : "", gobj_short_name(dst), state.state_name, event ? event : "", src && !src.running ? "!!" : "", gobj_short_name(src)));
2495
+ if (__trace_machine_format__ === 1) trace_machine(sprintf("🔜 %s %s%s %s", event ? event : "", !dst.running ? "!!" : "", gobj_short_name(dst), state.state_name));
2496
+ else trace_machine(sprintf("🔃 mach(%s%s), st: %s, ev: %s, from(%s%s)", !dst.running ? "!!" : "", gobj_short_name(dst), state.state_name, event ? event : "", src && !src.running ? "!!" : "", gobj_short_name(src)));
2494
2497
  if (kw) {
2495
2498
  if (tracea > 1) {
2496
2499
  if (json_object_size(kw)) trace_json(kw);
@@ -2871,8 +2874,9 @@ function gobj_publish_event(publisher, event, kw) {
2871
2874
  }
2872
2875
  let tracea = __yuno__ && gobj_read_bool_attr(__yuno__, "trace_subscriptions");
2873
2876
  if (tracea) {
2874
- trace_machine(sprintf("🔝🔝 mach(%s%s^%s), st: %s, ev: %s%s%s", !publisher.running ? "!!" : "", gobj_gclass_name(publisher), gobj_name(publisher), publisher.current_state.state_name, "", event ? event : "", ""));
2875
- trace_json(kw);
2877
+ if (__trace_machine_format__ === 1) trace_machine(sprintf("🔝🔝 %s %s%s %s", event ? event : "", !publisher.running ? "!!" : "", gobj_short_name(publisher), publisher.current_state.state_name));
2878
+ else trace_machine(sprintf("🔝🔝 mach(%s%s^%s), st: %s, ev: %s%s%s", !publisher.running ? "!!" : "", gobj_gclass_name(publisher), gobj_name(publisher), publisher.current_state.state_name, "", event ? event : "", ""));
2879
+ if (json_object_size(kw)) trace_json(kw);
2876
2880
  }
2877
2881
  if (publisher.gclass.gmt.mt_publish_event) {
2878
2882
  let topublish = publisher.gclass.gmt.mt_publish_event(publisher, event, kw);
@@ -2919,8 +2923,9 @@ function gobj_publish_event(publisher, event, kw) {
2919
2923
  if (__config__) {}
2920
2924
  if (__global__) json_object_update(kw2publish, __global__);
2921
2925
  if (tracea) {
2922
- trace_machine(sprintf("🔝🔄 mach(%s%s), st: %s, ev: %s, from(%s%s)", !subscriber.running ? "!!" : "", gobj_short_name(subscriber), gobj_current_state(subscriber), event ? event : "", publisher && !publisher.running ? "!!" : "", gobj_short_name(publisher)));
2923
- trace_json(kw2publish);
2926
+ if (__trace_machine_format__ === 1) trace_machine(sprintf("🔝🔄 %s (%s) %s%s", event ? event : "", event ? event : "", !subscriber.running ? "!!" : "", gobj_short_name(subscriber)));
2927
+ else trace_machine(sprintf("🔝🔄 mach(%s%s), st: %s, ev: %s, from(%s%s)", !subscriber.running ? "!!" : "", gobj_short_name(subscriber), gobj_current_state(subscriber), event ? event : "", publisher && !publisher.running ? "!!" : "", gobj_short_name(publisher)));
2928
+ if (json_object_size(kw2publish)) trace_json(kw2publish);
2924
2929
  }
2925
2930
  let ret_ = gobj_send_event(subscriber, event, kw2publish, publisher);
2926
2931
  if (ret_ < 0 && subs_flag & subs_flag_t.__own_event__) {