p-org / PSharp

A framework for rapid development of reliable asynchronous software.
MIT License
390 stars 37 forks source link

Printing Payload value in the Log generated #474

Closed ankushdesai closed 4 years ago

ankushdesai commented 4 years ago

Can you please help with how we can enable printing payload value in the events sent/received when generating the error trace.

This would be helpful to know by just looking at the log what messages are going around.

Currently, you print the Event name, instead, can you call the toString() function which by default returns the name of the event but we can then override this function if we want to print something else along with event name.

Thanks!

pdeligia commented 4 years ago

Hey @ankushdesai, we actually do not automatically print a payload value for an event, because the event can contain any arbitrary custom user data. We let the user to customize the log (besides the stuff that we automatically log already) in whatever way they want.

For example, one thing you could do to print the event payloads, is to instrument your own calls (in the generated machines) to the runtime logger (which is a property of the machine, this.Logger or this.Runtime.Logger), and call WriteLine on it, and then whatever you log there will become part of the trace, if that makes sense? You could either do that in the machine actions, or could even use one of our machine callbacks for this purpose (e.g. by overriding protected virtual Task OnEventDequeueAsync(Event e), which is called whenever an event is dequeued). Hope this helps!