LP-level printing is available from the forward event handler. Models simply need to attach an output buffer to the event being processed, using the tw_output function. If this event is eventually committed, all attached output will be sent to standard-out.

Example

1
2
3
4
void event_handler (state *s, tw_bf *bf, message *in_msg, tw_lp *lp) {
    // this output is associated with in_msg
    tw_output(lp, "this has printf functionality: %d %f %s\n", 1, 2.0, "three");
}

Argument 1: The lp you’re on (4th argument for your event handler).

Argument 2: Printf-style string, with specifiers (%-escaped codes).

A variable number of additional arguments are needed to pass data for each specifier.

Notes

  1. The tw_output() calls are associated with the event being processed.
  2. Multiple outputs can be attached to the same event.
  3. Output will always be in-order from an LP-perspective though the messages may be out-of-order from a global perspective. You may wish to include a timestamp for sorting.