In nearly all my functions I use Print to print errors. But when I use the effect specifier that my function needs I can no longer use Print because Print has the no_rollback effect. Any idea how I can use the specifiers and also log/print errors
When working with more restricted specifiers you’ll have to switch from using Print
to using the log
object APIs. Here is an example of setting them up and using them.
# The name of this class (ie. my_log_channel ) will automatically prepend your messages in the log. Ex: "my_log_channel: MyMessage"
my_log_channel := class(log_channel){}
my_device := class(creative_device):
# Create an instance of the `log` object.
Logger:log = log{ Channel := my_log_channel }
MyMethod()<transacts>:void =
# Printing to the log will work in <transacts> and <varies> contexts
Logger.Print("Something happened")
4 Likes
Yo thanks!