-
Notifications
You must be signed in to change notification settings - Fork 46
LP Printf
Justin M. LaPre edited this page Sep 30, 2013
·
2 revisions
We've rolled out event-based, reversible printing available in your event handler.
While in your forward event handler, you can attach output to the event being processed. If this event is eventually committed, all attached output will be sent to standard-out.
Arg 1: The lp you're on (4th argument for your event handler).
Arg 2: Printf-style string, with %-escaped codes.
Note 1: any tw_output()
calls are associated with the event being processed.
Note 2: multiple outputs can be attached to the same event.
Note 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.
Sample Code:
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");
}