Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

JS: Traces

Traces

The trace is the execution log of the framework. The machine level writes every event that enters a state machine, so it shows what occurred and in which order. It is the first tool for a browser application, and not the last.

Source code: src/gobj.js

A gobj traces at the union of three masks: the global mask, the mask of its gclass, and its own mask. Each of the three has a silencing partner, and the silencing side wins.


Levels

trace_level_t

The global levels, with the name that every function below accepts.

NameDescription
machineEvery event that enters a state machine.
create_deleteThe creation and the destruction of a gobj.
create_delete2The same, with the kw.
subscriptionsThe subscriptions.
start_stopThe start and the stop of a gobj.
ev_kwThe payload of the events.
authzsThe authorizations.
statesEach change of state.
gbuffersThe buffers.
timerThe timers.
fsThe file system.
liburingThe io_uring mixins. The browser does not use it.
timer_periodicThe periodic timers.
liburing_timerThe io_uring timer. The browser does not use it.
commandsThe commands.

Every function accepts three forms for level: the name from this table, a bit mask as a string of digits, or an empty value, which means every global level.


Global

gobj_set_global_trace(level, set)

Turns a level on or off for every gclass. Returns 0, or -1 when the level name does not exist.

gobj_set_global_trace("machine", true);

gobj_set_global_no_trace(level, set)

Silences a level for every gclass. It wins against gobj_set_global_trace().

gobj_global_trace_level()

Gives the global mask, as a number.

gobj_repr_global_trace_levels()

Gives the catalog of the global levels, as a list of records with name, bit, description and set. A development panel builds its list of switches from it.

gobj_set_deep_trace(value)

Turns everything on at the same time, for a session that hunts something. Returns 0.


Per gclass

gobj_set_gclass_trace(gclass, level, set)

Turns a level on or off for one gclass. gclass accepts the gclass itself or its name, so a caller that holds no handle gives the name. Returns 0, or -1 when the gclass or the level does not exist.

gobj_set_gclass_no_trace(gclass, level, set)

Silences a level for one gclass.

This is the pair that keeps a machine trace readable:

gobj_set_gclass_no_trace("C_TIMER", "machine", true);
gobj_set_global_no_trace("timer_periodic", true);

The machine level traces every event by design, and a timer is an event. A tick of one second buries what you follow, so silence the timers first.


Per gobj

gobj_set_gobj_trace(gobj, level, set)

Turns a level on or off for one gobj. Returns 0, or -1 when gobj is empty.

gobj_set_gobj_no_trace(gobj, level, set)

Silences a level for one gobj.

gobj_trace_level(gobj)

Gives the mask in force for a gobj: the union of the global mask, the mask of its gclass and its own. The C kernel computes it in the same way.

gobj_trace_no_level(gobj)

Gives the silencing mask in force for a gobj.


The format of the machine trace

gobj_set_trace_machine_format(format)

Chooses the format of the lines of the machine trace.

gobj_trace_machine_format()

Gives the format that is in force.


Write a trace

The four writers are in Logging: trace_msg() and trace_json() write a line and an object.